ZQuest Classic Coverage Report


Directory: src/
File: src/zq/zquest.cpp
Date: 2024-05-10 00:25:22
Exec Total Coverage
Lines: 2212 15926 13.9%
Functions: 40 757 5.3%
Branches: 1335 11587 11.5%

Line Branch Exec Source
1 #define MIDI_TRACK_BUFFER_SIZE 50
2
3 #include <memory>
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <cstring>
7 #include <sstream>
8 #include <ctype.h>
9 #include <assert.h>
10 #include <time.h>
11 #include <vector>
12 #include <filesystem>
13 #include <base/new_menu.h>
14
15 #include "dialog/info_lister.h"
16 #ifdef __APPLE__
17 // malloc.h is deprecated, but malloc also lives in stdlib
18 #include <stdlib.h>
19 #else
20 #include <malloc.h>
21 #endif
22
23 #include "zalleg/zalleg.h"
24 #include "base/qrs.h"
25 #include "base/dmap.h"
26 #include "base/msgstr.h"
27 #include "base/packfile.h"
28 #include "base/cpool.h"
29 #include "base/autocombo.h"
30 #include "base/render.h"
31 #include "base/version.h"
32 #include "zq/autocombo/autopattern_base.h"
33 #include "zq/autocombo/pattern_basic.h"
34 #include "zq/autocombo/pattern_flatmtn.h"
35 #include "zq/autocombo/pattern_fence.h"
36 #include "zq/autocombo/pattern_cakemtn.h"
37 #include "zq/autocombo/pattern_relational.h"
38 #include "zq/autocombo/pattern_dungeoncarve.h"
39 #include "zq/autocombo/pattern_dormtn.h"
40 #include "zq/autocombo/pattern_tiling.h"
41 #include "zq/autocombo/pattern_replace.h"
42 #include "zq/render_hotkeys.h"
43 #include "zq/render_minimap.h"
44 #include "zq/render_tooltip.h"
45 #include "base/misctypes.h"
46 #include "parser/Compiler.h"
47 #include "base/zc_alleg.h"
48 #include "particles.h"
49 #include "dialog/alert.h"
50 #include "dialog/alertfunc.h"
51 8 particle_list particles;
52 8 void setZScriptVersion(int32_t) { } //bleh...
53
54 #include <al5_img.h>
55 #include <loadpng.h>
56 #include <fmt/format.h>
57
58 #include "dialog/cheat_codes.h"
59 #include "dialog/set_password.h"
60 #include "dialog/foodlg.h"
61 #include "dialog/quest_rules.h"
62 #include "dialog/script_rules.h"
63 #include "dialog/headerdlg.h"
64 #include "dialog/ffc_editor.h"
65 #include "dialog/screen_data.h"
66 #include "dialog/edit_dmap.h"
67 #include "dialog/compilezscript.h"
68 #include "dialog/externs.h"
69
70 #include "base/gui.h"
71 #include "gui/jwin_a5.h"
72 #include "zc_list_data.h"
73 #include "gui/editbox.h"
74 #include "zq/zq_misc.h"
75 #include "zq/zq_tiles.h" // tile and combo code
76
77 #include "zq/zquest.h"
78 #include "zq/zquestdat.h"
79 #include "zq/ffasm.h"
80 #include "zq/render.h"
81
82 // the following are used by both zelda.cc and zquest.cc
83 #include "base/zdefs.h"
84 #include "base/qrs.h"
85 #include "tiles.h"
86 #include "base/colors.h"
87 #include "qst.h"
88 #include "base/zsys.h"
89 #include "base/zapp.h"
90 #include "play_midi.h"
91 #include "sound/zcmusic.h"
92
93 #include "midi.h"
94 #include "sprite.h"
95 #include "fontsdat.h"
96 #include "base/jwinfsel.h"
97 #include "zq/zq_class.h"
98 #include "subscr.h"
99 #include "zq/zq_subscr.h"
100 #include "zc/ffscript.h"
101 #include "gui/EditboxNew.h"
102 #include "sfx.h"
103 #include "zq/zq_custom.h" // custom items and guys
104 #include "zq/zq_strings.h"
105 #include "zq/questReport.h"
106 #include "zq/ffasmexport.h"
107 #include <fstream>
108 #include "base/module.h"
109 #include "drawing.h"
110 #include "zconsole/ConsoleLogger.h"
111 #include "colorname.h"
112 #include "zq/zq_hotkey.h"
113 #include "zq/package.h"
114 #include "zq/zq_files.h"
115 #include "music_playback.h"
116
117 extern CConsoleLoggerEx parser_console;
118
119 namespace fs = std::filesystem;
120
121 //Windows mmemory tools
122 #ifdef _WIN32
123 #include <windows.h>
124 #include <stdio.h>
125 #include <psapi.h>
126 #pragma comment(lib, "psapi.lib") // Needed to avoid linker issues. -Z
127 #endif
128
129 #ifdef __EMSCRIPTEN__
130 #include <emscripten/emscripten.h>
131 #endif
132
133 //SDL_Surface *sdl_screen;
134
135 #if defined(ALLEGRO_WINDOWS)
136 static const char *data_path_name = "win_data_path";
137 static const char *midi_path_name = "win_midi_path";
138 static const char *image_path_name = "win_image_path";
139 static const char *tmusic_path_name = "win_tmusic_path";
140 static const char *last_quest_name = "win_last_quest";
141 static const char *qtname_name = "win_qtname%d";
142 static const char *qtpath_name = "win_qtpath%d";
143 #elif defined(ALLEGRO_LINUX)
144 static const char *data_path_name = "linux_data_path";
145 static const char *midi_path_name = "linux_midi_path";
146 static const char *image_path_name = "linux_image_path";
147 static const char *tmusic_path_name = "linux_tmusic_path";
148 static const char *last_quest_name = "linux_last_quest";
149 static const char *qtname_name = "linux_qtname%d";
150 static const char *qtpath_name = "linux_qtpath%d";
151 #elif defined(__APPLE__)
152 static const char *data_path_name = "macosx_data_path";
153 static const char *midi_path_name = "macosx_midi_path";
154 static const char *image_path_name = "macosx_image_path";
155 static const char *tmusic_path_name = "macosx_tmusic_path";
156 static const char *last_quest_name = "macosx_last_quest";
157 static const char *qtname_name = "macosx_qtname%d";
158 static const char *qtpath_name = "macosx_qtpath%d";
159 #endif
160
161 #include "base/win32.h"
162
163 #include "zq/zq_init.h"
164 #include "zq/zq_doors.h"
165 #include "zq/zq_cset.h"
166 #include "zinfo.h"
167
168 #ifdef _MSC_VER
169 #include <crtdbg.h>
170
171 #endif
172
173 // MSVC fix
174 #if _MSC_VER >= 1900
175 FILE _iob[] = { *stdin, *stdout, *stderr };
176 extern "C" FILE * __cdecl __iob_func(void) { return _iob; }
177 #endif
178
179 extern byte monochrome_console;
180
181 #include "zconsole/ConsoleLogger.h"
182
183 extern CConsoleLoggerEx zscript_coloured_console;
184
185 uint8_t console_is_open = 0;
186 uint8_t __isZQuest = 1; //Shared functionscan reference this. -Z
187 bool is_zq_replay_test = false;
188
189 #include "base/util.h"
190
191 #ifdef __EMSCRIPTEN__
192 #include "base/emscripten_utils.h"
193 #endif
194
195 using namespace util;
196
197 using std::vector;
198 using std::map;
199 using std::stringstream;
200
201 8 FFScript FFCore;
202
203 void load_size_poses();
204 void do_previewtext();
205 bool do_slots(map<string, disassembled_script_data> &scripts, int assign_mode);
206 void do_script_disassembly(map<string, disassembled_script_data>& scripts, bool fromCompile);
207
208 int32_t startdmapxy[6] = {-1000, -1000, -1000, -1000, -1000, -1000};
209 bool cancelgetnum=false;
210
211 int32_t tooltip_timer=0, tooltip_maxtimer=30, tooltip_current_ffc=0;
212 int32_t mousecomboposition, combobrushoverride=-1;
213
214 int32_t original_playing_field_offset=0;
215 8 int32_t playing_field_offset=original_playing_field_offset;
216 int32_t passive_subscreen_height=56;
217 int32_t passive_subscreen_offset=0;
218
219 bool disable_saving=false, OverwriteProtection;
220 bool halt=false;
221 bool show_sprites=true;
222 bool show_hitboxes = false;
223 bool zq_ignore_item_ownership = true;
224
225 // Used to find FFC script names
226 vector<string> asffcscripts;
227 vector<string> asglobalscripts;
228 vector<string> asitemscripts;
229 vector<string> asnpcscripts;
230 vector<string> aseweaponscripts;
231 vector<string> aslweaponscripts;
232 vector<string> asplayerscripts;
233 vector<string> asdmapscripts;
234 vector<string> asscreenscripts;
235 vector<string> asitemspritescripts;
236 vector<string> ascomboscripts;
237 vector<string> asgenericscripts;
238 vector<string> assubscreenscripts;
239
240 vector<string> ZQincludePaths;
241
242 int32_t CSET_SIZE = 16;
243 int32_t CSET_SHFT = 4;
244 //editbox_data temp_eb_data;
245 /*
246 #define CSET(x) ((x)<<CSET_SHFT)
247 #define csBOSS 14
248 */
249
250 /*
251 enum { m_block, m_coords, m_flags, m_guy, m_warp, m_misc, m_layers,
252 m_menucount };
253 */
254 void update_combo_cycling();
255 void update_freeform_combos();
256
257 /*
258 #define MAXMICE 14
259 #define MAXARROWS 8
260 #define SHADOW_DEPTH 2
261 */
262 int32_t coord_timer=0, coord_frame=0;
263 int32_t blackout_color, zq_screen_w, zq_screen_h;
264 int32_t draw_mode=0;
265
266 8 size_and_pos minimap;
267 8 size_and_pos real_minimap;
268
269 8 size_and_pos minimap_zoomed;
270 8 size_and_pos real_minimap_zoomed;
271
272 8 size_and_pos map_page_bar[9];
273 int32_t mappage_count = 9;
274
275 8 size_and_pos combolist[MAX_COMBO_COLS];
276 8 size_and_pos combolistscrollers[MAX_COMBO_COLS];
277 int32_t num_combo_cols = MAX_COMBO_COLS;
278
279 8 size_and_pos compactbtn;
280 8 size_and_pos mainbar;
281
282 8 size_and_pos screrrorpos;
283
284 8 size_and_pos comboaliaslist[MAX_COMBO_COLS];
285 8 size_and_pos comboalias_preview;
286 8 size_and_pos combopool_preview;
287 8 size_and_pos combopool_prevbtn;
288
289 8 size_and_pos combo_merge_btn;
290
291 8 size_and_pos combo_preview;
292 8 size_and_pos combo_preview2;
293 8 size_and_pos combo_preview_text1;
294 8 size_and_pos combo_preview_text2;
295 8 size_and_pos combolist_window;
296 8 size_and_pos drawmode_btn;
297 8 size_and_pos main_panel;
298 8 size_and_pos squares_panel;
299 8 size_and_pos preview_panel;
300 8 size_and_pos layer_panel;
301 8 size_and_pos preview_text;
302
303 8 size_and_pos favorites_window;
304 8 size_and_pos favorites_list;
305 8 size_and_pos favorites_x;
306 8 size_and_pos favorites_infobtn;
307 8 size_and_pos favorites_zoombtn;
308 8 size_and_pos favorites_pgleft;
309 8 size_and_pos favorites_pgright;
310
311 8 size_and_pos commands_window;
312 8 size_and_pos commands_list;
313 8 size_and_pos commands_x;
314 8 size_and_pos commands_infobtn;
315 8 size_and_pos commands_zoombtn;
316 8 size_and_pos commands_txt;
317
318 8 size_and_pos squarepanel_swap_btn;
319 8 size_and_pos squarepanel_up_btn;
320 8 size_and_pos squarepanel_down_btn;
321 8 size_and_pos itemsqr_pos;
322 8 size_and_pos flagsqr_pos;
323 8 size_and_pos stairsqr_pos;
324 8 size_and_pos warparrival_pos;
325 8 size_and_pos warpret_pos[4];
326 8 size_and_pos enemy_prev_pos;
327
328 8 size_and_pos txtoffs_single;
329 8 size_and_pos txtoffs_double_1;
330 8 size_and_pos txtoffs_double_2;
331 int32_t panel_align = 1;
332
333 int32_t command_buttonwidth = 88;
334 int32_t command_buttonheight = 19;
335
336 int32_t layerpanel_buttonwidth = 58;
337 int32_t layerpanel_buttonheight = 16;
338
339 int32_t layerpanel_checkbox_hei = 13;
340 int32_t layerpanel_checkbox_wid = 13;
341
342 int32_t favorite_combos[MAXFAVORITECOMBOS];
343 byte favorite_combo_modes[MAXFAVORITECOMBOS];
344 bool ShowFavoriteComboModes;
345 byte FavoriteComboPage;
346
347 char comboprev_buf[512] = {0};
348 char comboprev_buf2[512] = {0};
349 FONT* txfont;
350
351 const char *roomtype_string[MAXROOMTYPES] =
352 {
353 "(None)","Special Item","Pay for Info","Secret Money","Gamble",
354 "Door Repair","Red Potion or Heart Container","Feed the Goriya","Triforce Check",
355 "Potion Shop","Shop","More Bombs","Leave Money or Life","10 Rupees",
356 "3-Stair Warp","Ganon","Zelda", "-<item pond>", "1/2 Magic Upgrade", "Learn Slash", "More Arrows","Take One Item"
357 };
358
359 const char *catchall_string[MAXROOMTYPES] =
360 {
361 "Generic Catchall","Special Item","Info Type","Amount","Generic Catchall","Repair Fee","Generic Catchall","Generic Catchall","Generic Catchall","Shop Type",
362 "Shop Type","Price","Price","Generic Catchall","Warp Ring","Generic Catchall","Generic Catchall", "Generic Catchall", "Generic Catchall",
363 "Generic Catchall", "Price","Shop Type","Bottle Shop Type"
364 };
365
366 #define MAXPOOLCOMBOS MAXFAVORITECOMBOS
367
368 struct cmbdat_pair
369 {
370 int32_t data;
371 byte cset;
372 10080 cmbdat_pair() { clear(); }
373 16380 void clear()
374 {
375 16380 data = -1;
376 16380 cset = 0;
377 16380 }
378 bool valid() const
379 {
380 return data > -1;
381 }
382 };
383 bool pool_dirty=true;
384 8 cmbdat_pair pool_combos[MAXPOOLCOMBOS];
385 static std::vector<byte> pool;
386
387 bool pool_valid()
388 {
389 if(pool_dirty)
390 {
391 pool.clear();
392 for(auto q = 0; q < MAXPOOLCOMBOS; ++q)
393 {
394 if(pool_combos[q].valid())
395 pool.push_back(q);
396 }
397 pool_dirty = false;
398 }
399 return pool.size() > 0;
400 }
401 cmbdat_pair const& get_pool_combo()
402 {
403 if(!pool_valid()) return pool_combos[0];
404 auto ind = zc_rand(pool.size()-1);
405 return pool_combos[pool.at(ind)];
406 }
407
408 int32_t mapscreen_x, mapscreen_y, mapscreensize, showedges, showallpanels;
409 int32_t mouse_scroll_h;
410
411
412 int32_t readsize, writesize;
413 bool fake_pack_writing=false;
414
415 int32_t showxypos_x;
416 int32_t showxypos_y;
417 int32_t showxypos_w;
418 int32_t showxypos_h;
419 int32_t showxypos_color;
420 int32_t showxypos_ffc=-1000;
421 bool showxypos_icon=false;
422
423 int32_t showxypos_cursor_x;
424 int32_t showxypos_cursor_y;
425 bool showxypos_cursor_icon=false;
426 int32_t showxypos_cursor_color;
427 bool showxypos_dummy = false;
428
429 bool canfill=true; //to prevent double-filling (which stops undos)
430 bool resize_mouse_pos=false; //for eyeball combos
431 int32_t lens_hint_item[MAXITEMS][2]; //aclk, aframe
432 int32_t lens_hint_weapon[MAXWPNS][5]; //aclk, aframe, dir, x, y
433 //int32_t mode, switch_mode, orig_mode;
434 int32_t tempmode=GFX_AUTODETECT;
435 RGB_MAP zq_rgb_table;
436 COLOR_MAP trans_table, trans_table2;
437 DATAFILE *zcdata=NULL;
438 MIDI *song=NULL;
439 BITMAP *menu1, *menu3, *mapscreenbmp, *tmp_scr, *screen2, *mouse_bmp[MOUSE_BMP_MAX][4], *mouse_bmp_1x[MOUSE_BMP_MAX][4], *icon_bmp[ICON_BMP_MAX][4], *flag_bmp[16][4], *select_bmp[2], *dmapbmp_small, *dmapbmp_large;
440 BITMAP *arrow_bmp[MAXARROWS],*brushbmp, *brushscreen; //*brushshadowbmp;
441 byte *colordata=NULL, *trashbuf=NULL;
442 itemdata *itemsbuf;
443 wpndata *wpnsbuf;
444 comboclass *combo_class_buf;
445 guydata *guysbuf;
446 item_drop_object item_drop_sets[MAXITEMDROPSETS];
447 8 newcombo curr_combo;
448 PALETTE RAMpal;
449 midi_info Midi_Info;
450 bool zq_showpal=false;
451 bool combo_cols=true;
452 bool is_compact = false;
453
454 int pixeldb = 1;
455 int infobg = 1;
456 bool large_merged_combopane = false;
457 bool compact_merged_combopane = true;
458 bool large_zoomed_fav = false;
459 bool compact_zoomed_fav = true;
460 bool large_zoomed_cmd = false;
461 bool compact_zoomed_cmd = true;
462
463 bool compact_square_panels = false;
464 int compact_active_panel = 0;
465
466 int combo_col_scale = 1;
467
468 std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
469 script_data *ffscripts[NUMSCRIPTFFC];
470 script_data *itemscripts[NUMSCRIPTITEM];
471 script_data *guyscripts[NUMSCRIPTGUYS];
472 script_data *lwpnscripts[NUMSCRIPTWEAPONS];
473 script_data *ewpnscripts[NUMSCRIPTWEAPONS];
474 script_data *globalscripts[NUMSCRIPTGLOBAL];
475 script_data *genericscripts[NUMSCRIPTSGENERIC];
476 script_data *playerscripts[NUMSCRIPTPLAYER];
477 script_data *screenscripts[NUMSCRIPTSCREEN];
478 script_data *dmapscripts[NUMSCRIPTSDMAP];
479 script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
480 script_data *comboscripts[NUMSCRIPTSCOMBODATA];
481 script_data *subscreenscripts[NUMSCRIPTSSUBSCREEN];
482
483 extern string zScript;
484 char zScriptBytes[512];
485 char zLastVer[512] = { 0 };
486 SAMPLE customsfxdata[WAV_COUNT];
487 uint8_t customsfxflag[WAV_COUNT>>3];
488 int32_t sfxdat=1;
489
490 int32_t onImport_ComboAlias();
491 int32_t onExport_ComboAlias();
492
493 void set_console_state();
494
495 void clearConsole()
496 {
497 if(!console_is_open) return;
498 zscript_coloured_console.cls(CConsoleLoggerEx::COLOR_BACKGROUND_BLACK);
499 zscript_coloured_console.gotoxy(0,0);
500 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
501 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"ZQuest Classic Logging Console\n");
502 }
503
504 void initConsole()
505 {
506 if(console_is_open) return;
507 console_is_open = 1;
508 set_console_state();
509 zscript_coloured_console.Create("ZQuest Classic Logging Console", 600, 200);
510 clearConsole();
511 }
512
513 void killConsole()
514 {
515 if(!console_is_open) return;
516 console_is_open = 0;
517 set_console_state();
518 zscript_coloured_console.kill();
519 }
520
521 int toggleConsole()
522 {
523 console_is_open ? killConsole() : initConsole();
524 zc_set_config("zquest","open_debug_console",console_is_open?1:0);
525 return D_O_K;
526 }
527
528 int showHotkeys()
529 {
530 hotkeys_toggle_display(!hotkeys_is_active());
531 return D_O_K;
532 }
533
534 typedef int32_t (*intF)();
535 typedef struct command_pair
536 {
537 char name[80];
538 int32_t flags;
539 intF command;
540 } command_pair;
541
542 extern map_and_screen map_page[MAX_MAPPAGE_BTNS];
543
544 int32_t do_OpenQuest()
545 {
546 return onOpen();
547 }
548
549 int32_t do_NewQuest()
550 {
551 //clear the panel recent screen buttons to prevent crashes from invalid maps
552 for ( int32_t q = 0; q < 9; q++ )
553 {
554 map_page[q].map = 0;
555 map_page[q].screen = 0;
556 }
557 Map.setCurrMap(0);
558 Map.setCurrScr(0);
559 return onNew();
560 }
561
562 extern int CheckerCol1, CheckerCol2;
563 int32_t alignment_arrow_timer=0;
564 int32_t Flip=0,Combo=0,CSet=2,current_combolist=0,current_comboalist=0,current_cpoollist=0,current_cautolist=0,current_mappage=0;
565 int32_t Flags=0,Flag=0,menutype=(m_block);
566 int MouseScroll = 0, SavePaths = 0, CycleOn = 0, ShowGrid = 0, GridColor = 15,
567 CmbCursorCol = 15, TilePgCursorCol = 15, CmbPgCursorCol = 15, TTipHLCol = 13,
568 TileProtection = 0, ComboProtection = 0, NoScreenPreview = 0, MMapCursorStyle = 0,
569 LayerDitherBG = -1, LayerDitherSz = 2, RulesetDialog = 0,
570 EnableTooltips = 0, TooltipsHighlight = 0, ShowFFScripts = 0, ShowSquares = 0,
571 ShowFFCs = 0, ShowInfo = 0, skipLayerWarning = 0, WarnOnInitChanged = 0,
572 DisableLPalShortcuts = 1, DisableCompileConsole = 0, numericalFlags = 0,
573 ActiveLayerHighlight = 0;
574 uint8_t InvalidBG = 0;
575 bool NoHighlightLayer0 = false;
576 int32_t FlashWarpSquare = -1, FlashWarpClk = 0; // flash the destination warp return when ShowSquares is active
577 uint8_t ViewLayer3BG = 0, ViewLayer2BG = 0;
578 int32_t window_width, window_height;
579 bool ShowFPS = false, SaveDragResize = false, DragAspect = false, SaveWinPos=false;
580 bool allowHideMouse = false;
581 double aspect_ratio = LARGE_H / double(LARGE_W);
582 int window_min_width = 0, window_min_height = 0;
583 int32_t ComboBrush = 0; //show the brush instead of the normal mouse
584 int32_t ComboBrushPause = 0; //temporarily disable the combo brush
585 int32_t FloatBrush = 0; //makes the combo brush float a few pixels up and left
586 int AutoBrush = 0; //Drag to size the brush on the combo panes
587 bool AutoBrushRevert = false; //Revert after placing
588 int LinkedScroll = 0;
589 //complete with shadow
590 int32_t OpenLastQuest = 0; //makes the program reopen the quest that was
591 //open at the time you quit
592 int32_t ShowMisalignments = 0; //makes the program display arrows over combos that are
593 //not aligned with the next screen.
594 int32_t AnimationOn = 0; //animate the combos in zquest?
595 int32_t AutoBackupRetention = 0; //use auto-backup feature? if so, how many backups (1-10) to keep
596 int32_t AutoSaveInterval = 0; //how often a timed autosave is made (not overwriting the current file)
597 int32_t UncompressedAutoSaves = 0; //should timed saves be uncompressed/encrypted?
598 int32_t KeyboardRepeatDelay = 0; //the time in milliseconds after holding down a key that the key starts to repeat
599 int32_t KeyboardRepeatRate = 0; //the time in milliseconds between each repetition of a repeated key
600
601 time_t auto_save_time_start, auto_save_time_current;
602 double auto_save_time_diff = 0;
603 int32_t AutoSaveRetention = 0; //how many autosaves of a quest to keep
604 int32_t ImportMapBias = 0; //tells what has precedence on map importing
605 int32_t BrushWidth=1, BrushHeight=1;
606 bool saved=true;
607 bool __debug=false;
608 //bool usetiles=true;
609 int32_t LayerMaskInt[7]={0};
610 int32_t CurrentLayer=0;
611 int32_t DuplicateAction[4]={0};
612 int32_t OnlyCheckNewTilesForDuplicates = 0;
613 int32_t try_recovering_missing_scripts = 0;
614
615 uint8_t PreFillTileEditorPage = 0, PreFillComboEditorPage = 0;
616 int32_t DMapEditorLastMaptileUsed = 0;
617
618 /*
619 , HorizontalDuplicateAction;
620 int32_t VerticalDuplicateAction, BothDuplicateAction;
621 */
622 word msg_count = 0;
623 int32_t LeechUpdate = 0;
624 int32_t LeechUpdateTiles = 0;
625 int32_t SnapshotFormat = 0;
626 byte SnapshotScale = 0;
627
628 byte Color = 0;
629 extern int32_t jwin_pal[jcMAX];
630 int32_t gui_colorset=99;
631
632 static int32_t combo_apos=0; //currently selected combo alias
633 int32_t alias_origin=0;
634 int32_t alias_cset_mod=0;
635
636 static int32_t combo_pool_pos=0; //currently selected combo pool
637 bool weighted_cpool = true;
638 bool cpool_prev_visible = false;
639
640 static int32_t combo_auto_pos=0; //currently selected autocombo
641 byte cauto_height = 1;
642
643 bool trip=false;
644
645 int32_t fill_type=1;
646
647 bool first_save=false;
648 char *filepath,*temppath,*midipath,*datapath,*imagepath,*tmusicpath,*last_timed_save;
649 string helpstr, zstringshelpstr;
650
651 ZCMUSIC *zcmusic = NULL;
652 ZCMIXER *zcmixer = NULL;
653 int32_t midi_volume = 255;
654 extern int32_t prv_mode;
655 int32_t prv_warp = 0;
656 int32_t prv_twon = 0;
657 int32_t ff_combo = 0;
658
659 int32_t Frameskip = 0, RequestedFPS = 60, zqUseWin32Proc = 1, ForceExit = 0;
660 int32_t zqColorDepth = 8;
661 int32_t joystick_index=0;
662
663 void set_last_timed_save(char const* buf)
664 {
665 if(buf && buf[0])
666 {
667 if(buf != last_timed_save)
668 strcpy(last_timed_save, buf);
669 }
670 else
671 {
672 last_timed_save[0] = 0;
673 buf = nullptr;
674 }
675 zc_set_config("zquest","last_timed_save",buf);
676 }
677
678 void loadlvlpal(int32_t level);
679 bool get_debug()
680 {
681 return __debug;
682 //return true;
683 }
684
685 void set_debug(bool d)
686 {
687 __debug=d;
688 return;
689 }
690
691 bool handle_quit()
692 {
693 if(onExit()==D_CLOSE)
694 return (exiting_program = true);
695 return false;
696 }
697 bool handle_close_btn_quit()
698 {
699 if(close_button_quit)
700 {
701 close_button_quit=false;
702 return handle_quit();
703 }
704 return false;
705 }
706 // **** Timers ****
707
708 volatile int32_t lastfps=0;
709 volatile int32_t framecnt=0;
710 volatile int32_t myvsync = 0;
711 size_t cpoolbrush_index = 0;
712
713 1603 void myvsync_callback()
714 {
715 1603 ++myvsync;
716 1603 }
717
718 END_OF_FUNCTION(myvsync_callback)
719
720 // quest data
721 zquestheader header;
722 byte midi_flags[MIDIFLAGS_SIZE];
723 byte music_flags[MUSICFLAGS_SIZE];
724 byte *quest_file;
725 int32_t msg_strings_size;
726 zctune *customtunes;
727 //emusic *enhancedMusic;
728 ZCHEATS zcheats;
729 byte use_cheats;
730 byte use_tiles;
731 // Note: may not be null-terminated (must refactor writecolordata to fix).
732 char palnames[MAXLEVELS][17];
733 char zquestdat_sig[52];
734 char qstdat_str[2048];
735
736 int32_t gme_track=0;
737
738 int32_t dlevel; // just here until gamedata is properly done
739
740 9 bool bad_version(int32_t ver)
741 {
742
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(ver < 0x170)
743 return true;
744
745 9 return false;
746 9 }
747
748 zfix HeroModifiedX()
749 {
750 if(resize_mouse_pos)
751 {
752 return (zfix)((gui_mouse_x()/mapscreensize)-((8*mapscreensize)-1)+(showedges?8:0));
753 }
754 else
755 {
756 return (zfix)(gui_mouse_x()-7);
757 }
758 }
759
760 zfix HeroModifiedY()
761 {
762 if(resize_mouse_pos)
763 {
764 return (zfix)((gui_mouse_y()/mapscreensize)-((8*mapscreensize)-1)-16+(showedges?16:0));
765 }
766 else
767 {
768 return (zfix)(gui_mouse_y()-7);
769 }
770 }
771
772
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu import_250_menu
773 32 {
774
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&DMaps", onImport_DMaps },
775
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Combo Table", onImport_Combos },
776
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Combo Alias", onImport_ComboAlias },
777 };
778
779
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu import_graphics
780 120 {
781
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Palettes", onImport_Pals },
782
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
783
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Tileset (&Full)", onImport_Tiles },
784
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Tile Pack", onImport_Tilepack },
785
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "T&ile Pack to...", onImport_Tilepack_To },
786
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
787
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Combo Set (Range)", onImport_Combos },
788
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Combo Pack (Full, 1:1)", onImport_Combopack },
789
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Combo Pack to... (Dest)", onImport_Combopack_To },
790
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
791
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Combo &Alias Pack", onImport_Comboaliaspack },
792
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Combo A&lias Pack to...", onImport_Comboaliaspack_To },
793
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
794
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Doorsets", onImport_Doorset },
795 };
796
797
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu import_menu
798 80 {
799
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Enemies", onImport_Guys },
800
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Map", onImport_Map },
801
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&DMaps", onImport_DMaps },
802
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Strings (.tsv)", onImport_StringsTSV },
803
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "String Table (deprecated)", onImport_Msgs },
804
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
805
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Graphics", &import_graphics },
806
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
807
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "2.50 (Broken)", &import_250_menu },
808 };
809
810
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu export_250_menu
811 40 {
812
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&DMaps", onExport_DMaps },
813
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Combo Table", onExport_Combos },
814
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Combo Alias", onExport_ComboAlias },
815
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Graphics Pack", onExport_ZGP },
816 };
817
818
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu zq_help_menu
819 24 {
820
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Editor Help", onHelp },
821
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Strings Help", onZstringshelp },
822 };
823
824
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu export_graphics
825 96 {
826
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Palettes", onExport_Pals },
827
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
828
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Tileset (&Full)", onExport_Tiles },
829
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Tile Pack", onExport_Tilepack },
830
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
831
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Combo Set", onExport_Combos },
832
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Combo Pack", onExport_Combopack },
833
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
834
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Combo &Alias Pack", onExport_Comboaliaspack },
835
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
836
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Doorsets", onExport_Doorset },
837 };
838
839
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu export_menu
840 88 {
841 #ifdef _WIN32
842 { "&Package", onExport_Package },
843 #endif
844
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Enemies", onExport_Guys },
845
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Map", onExport_Map },
846
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&DMaps", onExport_DMaps },
847
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
848
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Strings (.tsv)", onExport_StringsTSV },
849
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "String Table (deprecated)", onExport_Msgs },
850
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
851
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Graphics", &export_graphics },
852
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
853
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "2.50 (Broken)", &export_250_menu },
854 };
855
856
857
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu recent_menu
858 88 {
859
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
860
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
861
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
862
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
863
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
864
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
865
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
866
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
867
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
868
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
869 };
870 static char rec_menu_fullpaths[10][512];
871 static char rec_menu_strs[10][64];
872
873 int32_t customOpen(char const* path);
874 void do_recent_quest(uint32_t ind)
875 {
876 if(ind > 9) return;
877 strcpy(temppath, rec_menu_fullpaths[ind]);
878 customOpen(temppath);
879 }
880 int32_t do_RecentQuest_0() { do_recent_quest(0); return D_O_K; }
881 int32_t do_RecentQuest_1() { do_recent_quest(1); return D_O_K; }
882 int32_t do_RecentQuest_2() { do_recent_quest(2); return D_O_K; }
883 int32_t do_RecentQuest_3() { do_recent_quest(3); return D_O_K; }
884 int32_t do_RecentQuest_4() { do_recent_quest(4); return D_O_K; }
885 int32_t do_RecentQuest_5() { do_recent_quest(5); return D_O_K; }
886 int32_t do_RecentQuest_6() { do_recent_quest(6); return D_O_K; }
887 int32_t do_RecentQuest_7() { do_recent_quest(7); return D_O_K; }
888 int32_t do_RecentQuest_8() { do_recent_quest(8); return D_O_K; }
889 int32_t do_RecentQuest_9() { do_recent_quest(9); return D_O_K; }
890
891 2 void refresh_recent_menu()
892 {
893 2 int32_t (*procs[10])(void) = {
894 do_RecentQuest_0, do_RecentQuest_1, do_RecentQuest_2, do_RecentQuest_3,
895 do_RecentQuest_4, do_RecentQuest_5, do_RecentQuest_6,
896 do_RecentQuest_7, do_RecentQuest_8, do_RecentQuest_9
897 };
898
5/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
2 static MenuItem nilitem("---",nullptr,nullopt,true);
899
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 20 times.
22 for(auto q = 0; q < 10; ++q)
900 {
901 20 MenuItem& mit = *recent_menu.at(q);
902 20 bool valid = rec_menu_fullpaths[q][0] != '-';
903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(valid)
904 mit = MenuItem(rec_menu_strs[q],procs[q]);
905 20 else mit = nilitem;
906 20 }
907 2 }
908
909 1 void load_recent_quests()
910 {
911 1 char configname[64] = "rec_qst_";
912 1 char* ptr = &configname[strlen(configname)];
913 1 char buf[512] = {0};
914
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1 times.
11 for(auto q = 0; q < 10; ++q)
915 {
916 10 sprintf(ptr, "%d", q); //increment the configname value
917 10 char const* qst_str = zc_get_config("recent",configname,nullptr);
918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(qst_str[0])
919 {
920 strncpy(rec_menu_fullpaths[q], qst_str, 511);
921 relativize_path(buf, rec_menu_fullpaths[q]);
922 if(strlen(buf) > 62)
923 {
924 buf[60] = buf[61] = buf[62] = '.'; //add "..." as the last 3 characters
925 }
926 strncpy(rec_menu_strs[q], buf, 63);
927 }
928 else
929 {
930 10 strcpy(rec_menu_fullpaths[q], "---");
931 10 strcpy(rec_menu_strs[q], "---");
932 }
933 10 rec_menu_fullpaths[q][511] = 0;
934 10 rec_menu_strs[q][63] = 0;
935 10 }
936 1 refresh_recent_menu();
937 1 }
938
939 void write_recent_quests()
940 {
941 char configname[64] = "rec_qst_";
942 char* ptr = &configname[strlen(configname)];
943 for(auto q = 0; q < 10; ++q)
944 {
945 sprintf(ptr, "%d", q); //increment the configname value
946 zc_set_config("recent",configname,(rec_menu_fullpaths[q][0]!='-') ? rec_menu_fullpaths[q] : nullptr);
947 }
948 }
949
950 void update_recent_quest(char const* path)
951 {
952 int32_t ind = -1;
953 for(auto q = 0; q < 10; ++q)
954 {
955 if(!strcmp(path, rec_menu_fullpaths[q]))
956 {
957 ind = q;
958 break;
959 }
960 }
961 if(ind > -1)
962 {
963 for(auto q = ind; q > 0; --q)
964 {
965 strcpy(rec_menu_fullpaths[q], rec_menu_fullpaths[q-1]);
966 strcpy(rec_menu_strs[q], rec_menu_strs[q-1]);
967 }
968 }
969 else
970 {
971 int32_t free_ind = 9; //if none found, override the last index
972 for(auto q = 0; q < 9; ++q)
973 {
974 if(rec_menu_fullpaths[q][0] == '-')
975 {
976 free_ind = q;
977 break;
978 }
979 }
980
981 for(auto q = free_ind; q > 0; --q)
982 {
983 strcpy(rec_menu_fullpaths[q], rec_menu_fullpaths[q-1]);
984 strcpy(rec_menu_strs[q], rec_menu_strs[q-1]);
985 }
986 }
987 char buf[512] = {0};
988 strcpy(rec_menu_fullpaths[0], path);
989 relativize_path(buf, rec_menu_fullpaths[0]);
990 if(strlen(buf) > 62)
991 {
992 buf[60] = buf[61] = buf[62] = '.'; //add "..." as the last 3 characters
993 }
994 strncpy(rec_menu_strs[0], buf, 63);
995 refresh_recent_menu();
996 zc_set_config("zquest",last_quest_name,path);
997 write_recent_quests();
998 }
999
1000 void reload_zq_gui()
1001 {
1002 init_custom_fonts();
1003 load_size_poses();
1004 update_combobrush();
1005 refresh(rCLEAR|rALL);
1006 }
1007 void toggle_is_compact()
1008 {
1009 is_compact = !is_compact;
1010 zc_set_config("ZQ_GUI","compact_mode",is_compact?1:0);
1011 reload_zq_gui();
1012 }
1013 void toggle_merged_mode()
1014 {
1015 if(is_compact)
1016 {
1017 compact_merged_combopane = !compact_merged_combopane;
1018 zc_set_config("ZQ_GUI","merge_cpane_compact",compact_merged_combopane?1:0);
1019 }
1020 else
1021 {
1022 large_merged_combopane = !large_merged_combopane;
1023 zc_set_config("ZQ_GUI","merge_cpane_large",large_merged_combopane?1:0);
1024 }
1025 reload_zq_gui();
1026 }
1027 void toggle_compact_sqr_mode()
1028 {
1029 compact_square_panels = !compact_square_panels;
1030 zc_set_config("ZQ_GUI","square_panels_compact",compact_square_panels?1:0);
1031 reload_zq_gui();
1032 }
1033 void cycle_compact_sqr(bool down)
1034 {
1035 if(!(is_compact && compact_square_panels))
1036 return;
1037 static const int num_panels = 3;
1038 if(down)
1039 compact_active_panel = (compact_active_panel+1)%num_panels;
1040 else
1041 compact_active_panel = (compact_active_panel-1+num_panels)%num_panels;
1042 reload_zq_gui();
1043 }
1044 void toggle_favzoom_mode()
1045 {
1046 if(is_compact)
1047 {
1048 compact_zoomed_fav = !compact_zoomed_fav;
1049 zc_set_config("ZQ_GUI","zoom_fav_compact",compact_zoomed_fav?1:0);
1050 }
1051 else
1052 {
1053 large_zoomed_fav = !large_zoomed_fav;
1054 zc_set_config("ZQ_GUI","zoom_fav_large",large_zoomed_fav?1:0);
1055 }
1056 reload_zq_gui();
1057 }
1058 void toggle_cmdzoom_mode()
1059 {
1060 if(is_compact)
1061 {
1062 compact_zoomed_cmd = !compact_zoomed_cmd;
1063 zc_set_config("ZQ_GUI","zoom_cmd_compact",compact_zoomed_cmd?1:0);
1064 }
1065 else
1066 {
1067 large_zoomed_cmd = !large_zoomed_cmd;
1068 zc_set_config("ZQ_GUI","zoom_cmd_large",large_zoomed_cmd?1:0);
1069 }
1070 reload_zq_gui();
1071 }
1072
1073 enum
1074 {
1075 MENUID_FILE_SAVE,
1076 MENUID_FILE_SAVEAS,
1077 MENUID_FILE_REVERT,
1078 };
1079
1080
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu file_menu
1081 112 {
1082
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&New", do_NewQuest },
1083
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Open", do_OpenQuest },
1084
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Load Tileset", onTileset },
1085
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Recent", &recent_menu },
1086
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
1087
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Save", onSave, MENUID_FILE_SAVE },
1088
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Save &as...", onSaveAs, MENUID_FILE_SAVEAS },
1089
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Revert", onRevert, MENUID_FILE_REVERT },
1090
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
1091
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Import", &import_menu },
1092
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Export", &export_menu },
1093 #ifndef __EMSCRIPTEN__
1094
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
1095
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "E&xit", handle_quit },
1096 #endif
1097 };
1098
1099 enum
1100 {
1101 MENUID_MAPS_NEXT,
1102 MENUID_MAPS_PREV,
1103 };
1104
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu maps_menu
1105 48 {
1106
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Goto Map...", onGotoMap },
1107
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Next Map", onIncMap, MENUID_MAPS_NEXT },
1108
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Previous Map", onDecMap, MENUID_MAPS_PREV },
1109
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
1110
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "D&elete Map", onDeleteMap },
1111 };
1112
1113
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu misc_menu
1114 80 {
1115
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "S&ubscreens", onEditSubscreens },
1116
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Shop Types", onShopTypes },
1117
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Bottle Types", onBottleTypes },
1118
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Bottle S&hop Types", onBottleShopTypes },
1119
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Info Types", onInfoTypes },
1120
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Warp Rings", onWarpRings },
1121
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Triforce Pieces", onTriPieces },
1122
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&End String", onEndString },
1123
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Item &Drop Sets", onItemDropSets },
1124 };
1125
1126
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu spr_menu
1127 32 {
1128
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Sprite Data", onCustomWpns },
1129
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Player", onCustomHero },
1130
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Misc Sprites", onMiscSprites },
1131 };
1132
1133
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 NewMenu colors_menu
1134 32 {
1135
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Main ", onColors_Main },
1136
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Levels ", onColors_Levels },
1137
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Sprites ", onColors_Sprites },
1138 };
1139
1140
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu defs_menu
1141 72 {
1142
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Palettes", onDefault_Pals },
1143
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Tiles", onDefault_Tiles },
1144
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Combos", onDefault_Combos },
1145
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Items", onDefault_Items },
1146
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Enemies", onDefault_Guys },
1147
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Sprite Data", onDefault_Weapons },
1148
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Map Styles", onDefault_MapStyles },
1149
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "SF&X Data", onDefault_SFX },
1150 };
1151
1152 int32_t onEditComboAlias();
1153 int32_t onEditComboPool();
1154 int32_t onEditAutoCombo();
1155
1156
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu graphics_menu
1157 80 {
1158
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Palettes ", &colors_menu },
1159
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Sprites ", &spr_menu },
1160
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Combos", onCombos },
1161
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Tiles", onTiles },
1162
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Game icons", onIcons },
1163
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Misc co&lors", onMiscColors },
1164
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Map styles", onMapStyles },
1165
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Door Combo Sets", onDoorCombos },
1166
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Combo &Aliases", onEditComboAlias },
1167 };
1168
1169
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu audio_menu
1170 32 {
1171
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "SF&X Data", onSelectSFX },
1172
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&MIDIs", onMidis },
1173
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Mis&c SFX", onMiscSFX },
1174 };
1175
1176 void set_rules(byte* newrules);
1177
1178 void call_testqst_dialog();
1179 int32_t onTestQst()
1180 {
1181 call_testqst_dialog();
1182 return D_O_K;
1183 }
1184
1185 int32_t onRulesDlg()
1186 {
1187 call_qr_dialog(21, set_rules);
1188 return D_O_K;
1189 }
1190
1191 int32_t onRulesSearch()
1192 {
1193 call_qrsearch_dialog(set_rules);
1194 return D_O_K;
1195 }
1196
1197 int32_t onZScriptSettings()
1198 {
1199 ScriptRulesDialog(quest_rules, 17, [](byte* newrules)
1200 {
1201 saved = false;
1202 memcpy(quest_rules, newrules, QR_SZ);
1203 unpack_qrs();
1204 }).show();
1205 return D_O_K;
1206 }
1207
1208 void call_zinf_dlg();
1209 int32_t onZInfo()
1210 {
1211 call_zinf_dlg();
1212 return D_O_K;
1213 }
1214
1215
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu quest_menu
1216 144 {
1217
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Options ", onRulesDlg },
1218
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Test", onTestQst },
1219
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Items", onCustomItems },
1220
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Ene&mies", onCustomEnemies },
1221
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Player", onCustomHero },
1222
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Strings", onStrings },
1223
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&DMaps", onDmaps },
1224
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "I&nit Data", onInit },
1225
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Misc D&ata ", &misc_menu },
1226
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&ZInfo", onZInfo },
1227
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
1228
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Graphics ", &graphics_menu },
1229
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "A&udio ", &audio_menu },
1230
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
1231
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "De&faults ", &defs_menu },
1232
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
1233
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Misc[]", onQMiscValues },
1234 };
1235
1236
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu paste_menu
1237 24 {
1238
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Paste &To All", onPasteToAll },
1239
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Paste &All To All", onPasteAllToAll },
1240 };
1241
1242
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu paste_item_menu
1243 104 {
1244
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Undercombo", onPasteUnderCombo },
1245
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Secret Combos", onPasteSecretCombos },
1246
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Freeform Combos", onPasteFFCombos },
1247
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Screen &Data", onPasteScreenData },
1248
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Warps", onPasteWarps },
1249
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Warp &Return", onPasteWarpLocations },
1250
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Enemies", onPasteEnemies },
1251
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Room &Type Data", onPasteRoom },
1252
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Guy/String", onPasteGuy },
1253
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Doo&rs", onPasteDoors },
1254
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Layers", onPasteLayers },
1255
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Palette", onPastePalette },
1256 };
1257
1258 enum
1259 {
1260 MENUID_EDIT_UNDO,
1261 MENUID_EDIT_REDO,
1262 MENUID_EDIT_COPY,
1263 MENUID_EDIT_PASTE,
1264 MENUID_EDIT_PASTEALL,
1265 MENUID_EDIT_ADVPASTE,
1266 MENUID_EDIT_SPECPASTE,
1267 MENUID_EDIT_DELETE,
1268 };
1269
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu edit_menu
1270 88 {
1271
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Undo", onUndo, MENUID_EDIT_UNDO },
1272
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Redo", onRedo, MENUID_EDIT_REDO },
1273
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Copy", onCopy, MENUID_EDIT_COPY },
1274
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Paste", onPaste, MENUID_EDIT_PASTE },
1275
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Paste A&ll", onPasteAll, MENUID_EDIT_PASTEALL },
1276
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Adv. Paste ", &paste_menu, MENUID_EDIT_ADVPASTE },
1277
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Paste &Spec. ", &paste_item_menu, MENUID_EDIT_SPECPASTE },
1278
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Delete", onDelete, MENUID_EDIT_DELETE },
1279
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
1280
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Maps ", &maps_menu },
1281 };
1282
1283
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu drawing_mode_menu
1284 40 {
1285
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Normal", onDrawingModeNormal, dm_normal },
1286
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Combo Alias", onDrawingModeAlias, dm_alias },
1287
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Pool", onDrawingModePool, dm_cpool },
1288
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Auto Combo", onDrawingModeAuto, dm_auto },
1289 };
1290
1291
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu integrity_check_menu
1292 32 {
1293
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&All ", onIntegrityCheckAll },
1294
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Screens ", onIntegrityCheckRooms },
1295
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Warps ", onIntegrityCheckWarps },
1296 };
1297
1298
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu quest_reports_menu
1299 72 {
1300
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Bugged Next-> Combo Locations", onBuggedNextComboLocationReport },
1301
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Combo Locations", onComboLocationReport },
1302
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Combo Type Locations", onComboTypeLocationReport },
1303
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Enemy Locations", onEnemyLocationReport },
1304
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Item Locations", onItemLocationReport },
1305
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Script Locations", onScriptLocationReport },
1306
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&What Links Here", onWhatWarpsReport },
1307
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "In&tegrity Check ", &integrity_check_menu },
1308 };
1309
1310 int32_t onPalFix();
1311 int32_t onPitFix();
1312 int32_t onStrFix()
1313 {
1314 if(get_qr(qr_OLD_STRING_EDITOR_MARGINS))
1315 {
1316 AlertDialog("Fix: Old Margins",
1317 "Fixing margins may cause strings that used to spill outside the textbox"
1318 " to instead be cut off. Are you sure?",
1319 [&](bool ret,bool)
1320 {
1321 if(ret)
1322 {
1323 set_qr(qr_OLD_STRING_EDITOR_MARGINS, 0);
1324 saved = false;
1325 }
1326 }).show();
1327 }
1328 if(get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT))
1329 {
1330 AlertDialog("Fix: Old Frame Size",
1331 "This will fix the frame size of all strings. No visual changes should occur,"
1332 " as the string width/height will be fixed, but the compat QR will also be unchecked.",
1333 [&](bool ret,bool)
1334 {
1335 if(ret)
1336 {
1337 for(auto q = 0; q < msg_count; ++q)
1338 {
1339 MsgStrings[q].w += 16;
1340 MsgStrings[q].h += 16;
1341 }
1342 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT, 0);
1343 saved = false;
1344 }
1345 }).show();
1346 }
1347 return D_O_K;
1348 }
1349
1350 enum
1351 {
1352 MENUID_FIXTOOL_OLDSTRING,
1353 };
1354
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu fixtools_menu
1355 56 {
1356
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Color Set Fix", onCSetFix },
1357
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Liquid Solidity Fix", onWaterSolidity },
1358
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Effect Square Fix", onEffectFix },
1359
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Level Palette Fix", onPalFix },
1360
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Pit and Liquid Damage Fix", onPitFix },
1361
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Old Strings Fix", onStrFix, MENUID_FIXTOOL_OLDSTRING },
1362 };
1363
1364
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu tool_menu
1365 88 {
1366
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Combo &Flags", onFlags, nullopt, MFL_EXIT_PRE_PROC },
1367
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Fix &Tools ", &fixtools_menu },
1368
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&NES Dungeon Template", onTemplate },
1369
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Apply Template to All", onReTemplate },
1370
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
1371
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Preview Mode", onPreviewMode },
1372
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Drawing &Mode ", &drawing_mode_menu },
1373
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
1374
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&List Combos Used", onUsedCombos },
1375
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Quest Reports ", &quest_reports_menu },
1376 };
1377
1378 int32_t onLayer3BG()
1379 {
1380 ViewLayer3BG = ViewLayer3BG ? 0 : 1;
1381 zc_set_config("zquest","layer3_bg",ViewLayer3BG);
1382 return D_O_K;
1383 }
1384 int32_t onLayer2BG()
1385 {
1386 ViewLayer2BG = ViewLayer2BG ? 0 : 1;
1387 zc_set_config("zquest","layer2_bg",ViewLayer2BG);
1388 return D_O_K;
1389 }
1390 int onGridToggle();
1391 enum
1392 {
1393 MENUID_VIEW_WALKABILITY,
1394 MENUID_VIEW_FLAGS,
1395 MENUID_VIEW_CSET,
1396 MENUID_VIEW_TYPES,
1397 MENUID_VIEW_INFO,
1398 MENUID_VIEW_SQUARES,
1399 MENUID_VIEW_FFCS,
1400 MENUID_VIEW_SCRIPTNAMES,
1401 MENUID_VIEW_GRID,
1402 MENUID_VIEW_DARKNESS,
1403 MENUID_VIEW_L2BG,
1404 MENUID_VIEW_L3BG,
1405 MENUID_VIEW_LAYERHIGHLIGHT,
1406 };
1407
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 NewMenu view_menu
1408 144 {
1409
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "View &Map...", onViewMap },
1410
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "View &Palette", onShowPal },
1411
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
1412
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Show &Walkability", onShowWalkability, MENUID_VIEW_WALKABILITY },
1413
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Show &Flags", onShowFlags, MENUID_VIEW_FLAGS },
1414
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Show &CSets", onShowCSet, MENUID_VIEW_CSET },
1415
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Show &Types", onShowCType, MENUID_VIEW_TYPES },
1416
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
1417
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Show Screen &Info", onToggleShowInfo, MENUID_VIEW_INFO },
1418
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Show &Squares", onToggleShowSquares, MENUID_VIEW_SQUARES },
1419
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Show FFCs", onToggleShowFFCs, MENUID_VIEW_FFCS },
1420
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Show Script &Names", onToggleShowScripts, MENUID_VIEW_SCRIPTNAMES },
1421
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Show &Grid", onGridToggle, MENUID_VIEW_GRID },
1422
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Show &Darkness", onShowDarkness, MENUID_VIEW_DARKNESS },
1423
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Layer 2 is Background", onLayer2BG, MENUID_VIEW_L2BG },
1424
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Layer 3 is Background", onLayer3BG, MENUID_VIEW_L3BG },
1425
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Highlight Current Layer", onToggleHighlightLayer, MENUID_VIEW_LAYERHIGHLIGHT },
1426 };
1427
1428 8 void set_rules(byte* newrules)
1429 {
1430 8 saved = false;
1431
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(newrules != quest_rules)
1432 memcpy(quest_rules, newrules, QR_SZ);
1433 8 unpack_qrs();
1434
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
1435 {
1436 2 combobuf[0].walk = 0xF0;
1437 2 combobuf[0].type = 0;
1438 2 combobuf[0].flag = 0;
1439 2 }
1440
1441 // For 2.50.0 and 2.50.1
1442
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 if(get_qr(qr_VERYFASTSCROLLING))
1443 2 set_qr(qr_FASTDNGN, 1);
1444 8 }
1445
1446 int32_t onSelectFFCombo();
1447
1448 void onScreenNotes()
1449 {
1450 edit_screen_notes(Map.CurrScr(), Map.getCurrMap(), Map.getCurrScr());
1451 }
1452
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu data_menu
1453 144 {
1454
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Screen Data", onScrData },
1455
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Freeform Combos", onSelectFFCombo },
1456
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "La&yers", onLayers },
1457
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Tile Warp", onTileWarp },
1458
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Side &Warp", onSideWarp },
1459
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Secret &Combos", onSecretCombo },
1460
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Under Combo", onUnderCombo },
1461
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Doors", onDoors },
1462
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Maze Path", onPath },
1463
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
1464
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Item", onItem },
1465
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Enemies", onEnemies },
1466
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Palette", onScreenPalette },
1467
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
1468
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Room Data", onRoom },
1469
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Notes", onScreenNotes },
1470
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Browse Notes", browse_screen_notes },
1471 };
1472
1473
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu tunes_menu
1474 168 {
1475
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "ZC Forever", playZCForever },
1476
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Wind Fish", playTune1 },
1477
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Overworld", playTune2 },
1478
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Hyrule Castle", playTune3 },
1479
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Lost Woods", playTune4 },
1480
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Great Sea", playTune5 },
1481
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "East Hyrule", playTune6 },
1482
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Dancing Dragon", playTune7 },
1483
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Stone Tower", playTune8 },
1484
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Villages", playTune9 },
1485
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Swamp + Desert", playTune10 },
1486
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Outset Island", playTune11 },
1487
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Kakariko Village", playTune12 },
1488
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Clock Town", playTune13 },
1489
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Temple", playTune14 },
1490
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Dark World", playTune15 },
1491
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Dragon Roost", playTune16 },
1492
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Horse Race", playTune17 },
1493
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Credits", playTune18 },
1494
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Zelda's Lullaby", playTune19 },
1495 };
1496
1497 enum
1498 {
1499 MENUID_MEDIA_TUNES,
1500 MENUID_MEDIA_PLAYMUSIC,
1501 MENUID_MEDIA_CHANGETRACK,
1502 };
1503
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu media_menu
1504 40 {
1505
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Ambient Music ", &tunes_menu, MENUID_MEDIA_TUNES },
1506
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Play music", playMusic, MENUID_MEDIA_PLAYMUSIC },
1507
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Change track", changeTrack, MENUID_MEDIA_CHANGETRACK },
1508
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Stop tunes", stopMusic },
1509 };
1510
1511 enum
1512 {
1513 MENUID_ETC_VIDMODE,
1514 MENUID_ETC_FULLSCREEN,
1515 MENUID_ETC_DEBUG_CONSOLE,
1516 };
1517
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu etc_menu
1518 128 {
1519
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Help", &zq_help_menu },
1520
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&About", onAbout },
1521
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Video Mode", onZQVidMode, MENUID_ETC_VIDMODE },
1522
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Options...", onOptions },
1523
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Hotkeys...", do_zq_hotkey_dialog },
1524
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&List Hotkeys...", do_zq_list_hotkeys_dialog },
1525
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Fullscreen", onFullScreen, MENUID_ETC_FULLSCREEN },
1526
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
1527
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&View Pic...", onViewPic },
1528
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Media", &media_menu },
1529
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
1530
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Debug Console", toggleConsole, MENUID_ETC_DEBUG_CONSOLE },
1531
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Clear Quest Filepath", onClearQuestFilepath },
1532
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Take ZQ Snapshot", onSnapshot },
1533
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Take &Screen Snapshot", onMapscrSnapshot },
1534 };
1535
1536
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu zscript_menu
1537 56 {
1538
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Compile &ZScript...", onCompileScript },
1539
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
1540
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Compiler Settings", onZScriptCompilerSettings },
1541
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Quest Script Settings", onZScriptSettings },
1542
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 {},
1543
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Import ZASM Script", onImportZASM },
1544 };
1545
1546 void set_console_state()
1547 {
1548 etc_menu.select_uid(MENUID_ETC_DEBUG_CONSOLE, console_is_open);
1549 }
1550
1551
3/16
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
8 NewMenu foo_menu{{"FOO",[](){InfoDialog("PLACEHOLDER","THIS IS A PLACEHOLDER").show();}}};
1552
1553
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 TopMenu the_menu
1554 72 {
1555
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&File", &file_menu },
1556
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Quest", &quest_menu },
1557
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Edit", &edit_menu },
1558
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&View", &view_menu },
1559
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Tools", &tool_menu },
1560
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&Screen", &data_menu },
1561
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "&ZScript", &zscript_menu },
1562
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Et&C", &etc_menu },
1563 };
1564
1565 void rebuild_trans_table();
1566 int32_t launchPicViewer(BITMAP **pictoview, PALETTE pal,
1567 int32_t *px2, int32_t *py2, double *scale, bool isviewingmap, bool skipmenu = false);
1568
1569 int32_t onResetTransparency()
1570 {
1571 restore_mouse();
1572 rebuild_trans_table();
1573 jwin_alert("Notice","Translucency Table Rebuilt",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
1574
1575 refresh(rALL);
1576 return D_O_K;
1577 }
1578
1579 int32_t onFullScreen()
1580 {
1581 get_palette(RAMpal);
1582 bool windowed=is_windowed_mode()!=0;
1583 all_toggle_fullscreen(windowed);
1584
1585 gui_mouse_focus=0;
1586 gui_bg_color=jwin_pal[jcBOX];
1587 gui_fg_color=jwin_pal[jcBOXFG];
1588 MouseSprite::set(ZQM_NORMAL);
1589 zc_set_palette(RAMpal);
1590 position_mouse(zq_screen_w/2,zq_screen_h/2);
1591 set_display_switch_mode(SWITCH_BACKGROUND);
1592 set_display_switch_callback(SWITCH_OUT, switch_out);
1593 set_display_switch_callback(SWITCH_IN, switch_in);
1594 zc_set_config("zquest","fullscreen", is_windowed_mode() ? 0 : 1);
1595 return D_REDRAW;
1596 }
1597
1598 int32_t onEnter()
1599 {
1600 if(key[KEY_ALT]||key[KEY_ALTGR])
1601 {
1602 return onFullScreen();
1603 }
1604
1605 return D_O_K;
1606 }
1607
1608 //PROC, x, y, w, h, fg, bg, key, flags, d1, d2, *dp, *dp2, *dp3
1609
1610 //*text, (*proc), *child, flags, *dp
1611
1612 void run_zq_frame();
1613 int32_t d_nbmenu_proc(int32_t msg,DIALOG *d,int32_t c);
1614
1615
1616 /*int32_t onY()
1617 {
1618 return D_O_K;
1619 }*/
1620
1621 int32_t onToggleGrid(bool color)
1622 {
1623 if(color)
1624 {
1625 GridColor=(GridColor+8)%16;
1626 zc_set_config("zquest", "grid_color", GridColor);
1627 }
1628 else
1629 {
1630 ShowGrid=!ShowGrid;
1631 zc_set_config("zquest","show_grid",ShowGrid);
1632 }
1633
1634 return D_O_K;
1635 }
1636 int onGridToggle()
1637 {
1638 return onToggleGrid(CHECK_CTRL_CMD);
1639 }
1640
1641 int32_t onToggleShowScripts()
1642 {
1643 ShowFFScripts=!ShowFFScripts;
1644 zc_set_config("zquest","showffscripts",ShowFFScripts);
1645 return D_O_K;
1646 }
1647
1648 int32_t onToggleShowFFCs()
1649 {
1650 ShowFFCs=!ShowFFCs;
1651 zc_set_config("zquest","showffcs",ShowFFCs);
1652 return D_O_K;
1653 }
1654
1655 int32_t onToggleShowSquares()
1656 {
1657 ShowSquares=!ShowSquares;
1658 zc_set_config("zquest","showsquares",ShowSquares);
1659 return D_O_K;
1660 }
1661
1662 int32_t onToggleShowInfo()
1663 {
1664 ShowInfo=!ShowInfo;
1665 zc_set_config("zquest","showinfo",ShowInfo);
1666 return D_O_K;
1667 }
1668
1669 int32_t onToggleHighlightLayer()
1670 {
1671 ActiveLayerHighlight = ActiveLayerHighlight ? 0 : 1;
1672 zc_set_config("zquest","hl_active_lyr",ActiveLayerHighlight);
1673 return D_O_K;
1674 }
1675
1676 int onKeySlash()
1677 {
1678 if(key[KEY_LSHIFT] || key[KEY_RSHIFT])
1679 {
1680 onAbout();
1681 }
1682 return D_O_K;
1683 }
1684
1685 int onAKey()
1686 {
1687 if(prv_mode)
1688 Map.set_prvadvance(1);
1689 return D_O_K;
1690 }
1691
1692 int onReloadPreview()
1693 {
1694 if(prv_mode)
1695 {
1696 Map.set_prvscr(Map.get_prv_map(), Map.get_prv_scr());
1697 Map.set_prvcmb(0);
1698 }
1699 return D_O_K;
1700 }
1701 int onSecretsPreview()
1702 {
1703 if(prv_mode)
1704 {
1705 Map.prv_secrets(false);
1706 refresh(rALL);
1707 }
1708 return D_O_K;
1709 }
1710
1711 int onSKey()
1712 {
1713 if(CHECK_CTRL_CMD)
1714 {
1715 if(key[KEY_LSHIFT] || key[KEY_RSHIFT])
1716 {
1717 onSaveAs();
1718 }
1719 else
1720 {
1721 if(!saved)
1722 onSave();
1723 }
1724 }
1725 else if(prv_mode)
1726 {
1727 Map.prv_secrets(false);
1728 refresh(rALL);
1729 }
1730 else onStrings();
1731 return D_O_K;
1732 }
1733 int onSetNewLayer(int newlayer)
1734 {
1735 CurrentLayer = newlayer;
1736 refresh(rALL);
1737 return D_O_K;
1738 }
1739 void lpal_dsa()
1740 {
1741 info_dsa("Level Palette Shortcuts",
1742 "You currently have level palette shortcuts disabled."
1743 " These can be re-enabled in 'Etc->Options', on the toggle 'Disable Level Palette Shortcuts'.",
1744 "dsa_lpal");
1745 }
1746 int onScreenLPal(int lpal)
1747 {
1748 if(DisableLPalShortcuts)
1749 {
1750 lpal_dsa();
1751 return D_O_K;
1752 }
1753 saved=false;
1754 Map.setcolor(lpal);
1755 refresh(rSCRMAP);
1756 return D_O_K;
1757 }
1758
1759 int32_t onPressEsc()
1760 {
1761 if(zoomed_minimap)
1762 mmap_set_zoom(false);
1763 else return onExit();
1764 return D_O_K;
1765 }
1766
1767 static DIALOG dialogs[] =
1768 {
1769 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
1770 { d_nbmenu_proc, 0, 0, 0, 13, 0, 0, 0, D_USER, 0, 0, (void *) &the_menu, NULL, NULL },
1771 { d_zq_hotkey_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
1772
1773 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
1774 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_ESC, 0, (void *) onPressEsc, NULL, NULL },
1775 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 39, 0, 0, 0, (void *) onUsedCombos, NULL, NULL },
1776 { d_vsync_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
1777 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
1778 };
1779
1780
1781 int32_t onDecColour()
1782 {
1783 if ( CHECK_CTRL_CMD )
1784 {
1785 return onDecScrPal16();
1786 }
1787
1788 else if ( key[KEY_LSHIFT] || key[KEY_RSHIFT] )
1789 {
1790 return onDecScrPal();
1791 }
1792
1793 else
1794 {
1795 return onDecreaseCSet();
1796 }
1797 }
1798
1799 int32_t onIncColour()
1800 {
1801
1802 if ( CHECK_CTRL_CMD )
1803 {
1804 return onIncScrPal16();
1805 }
1806
1807 else if ( key[KEY_LSHIFT] || key[KEY_RSHIFT] )
1808 {
1809 return onIncScrPal();
1810 }
1811
1812 else
1813 {
1814 return onIncreaseCSet();
1815 }
1816 }
1817
1818 static DIALOG getnum_dlg[] =
1819 {
1820 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
1821 8 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
1822 8 { jwin_rtext_proc, 114, 104+4, 48, 8, jwin_pal[jcBOXFG], jwin_pal[jcBOX], 0, 0, 0, 0, (void *) "Value:", NULL, NULL },
1823 8 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
1824 8 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
1825 8 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
1826 8 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
1827 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
1828 };
1829
1830 int32_t getnumber(const char *prompt,int32_t initialval)
1831 {
1832 cancelgetnum=true;
1833 char buf[20];
1834 sprintf(buf,"%d",initialval);
1835 getnum_dlg[0].dp=(void *)prompt;
1836 getnum_dlg[0].dp2=get_zc_font(font_lfont);
1837 getnum_dlg[2].dp=(void *)buf;
1838
1839 large_dialog(getnum_dlg);
1840
1841 int32_t ret=do_zqdialog(getnum_dlg,2);
1842
1843 if(ret!=0&&ret!=4)
1844 {
1845 cancelgetnum=false;
1846 }
1847
1848 if(ret==3)
1849 return atoi(buf);
1850
1851 return initialval;
1852 }
1853
1854 static DIALOG save_tiles_dlg[] =
1855 {
1856 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
1857
1858
1859 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Save Tile Pack", NULL, NULL },
1860 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
1861 //for future tabs
1862 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
1863 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
1864 //4
1865 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First", NULL, NULL },
1866 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
1867 //6
1868 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
1869 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
1870 //8
1871 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Save", NULL, NULL },
1872 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
1873 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
1874 };
1875
1876
1877 void savesometiles(const char *prompt,int32_t initialval)
1878 {
1879
1880 char firsttile[8], tilecount[8];
1881 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
1882 sprintf(firsttile,"%d",0);
1883 sprintf(tilecount,"%d",1);
1884 //int32_t ret;
1885
1886
1887
1888 save_tiles_dlg[0].dp2 = get_zc_font(font_lfont);
1889
1890 sprintf(firsttile,"%d",0);
1891 sprintf(tilecount,"%d",1);
1892
1893 save_tiles_dlg[5].dp = firsttile;
1894 save_tiles_dlg[7].dp = tilecount;
1895
1896 large_dialog(save_tiles_dlg);
1897
1898 int32_t ret = do_zqdialog(save_tiles_dlg,-1);
1899 jwin_center_dialog(save_tiles_dlg);
1900
1901 if(ret == 8)
1902 {
1903 first_tile_id = vbound(atoi(firsttile), 0, NEWMAXTILES);
1904 the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
1905 if(getname("Save ZTILE(.ztile)", "ztile", NULL,datapath,false))
1906 {
1907 char name[PATH_MAX];
1908 extract_name(temppath,name,FILENAMEALL);
1909 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
1910 if(f)
1911 {
1912 writetilefile(f,first_tile_id,the_tile_count);
1913 pack_fclose(f);
1914 char tmpbuf[PATH_MAX+20]={0};
1915 sprintf(tmpbuf,"Saved %s",name);
1916 jwin_alert("Success!",tmpbuf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
1917 }
1918 }
1919 }
1920 }
1921
1922 static DIALOG read_tiles_dlg[] =
1923 {
1924 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
1925
1926
1927 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Load Tilepack To:", NULL, NULL },
1928 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
1929 //for future tabs
1930 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
1931 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
1932 //4
1933 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Starting at:", NULL, NULL },
1934 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
1935 //6
1936 { d_dummy_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
1937 { d_dummy_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
1938 //8
1939 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
1940 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
1941 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
1942 };
1943
1944
1945 void writesometiles_to(const char *prompt,int32_t initialval)
1946 {
1947
1948 char firsttile[8];;
1949 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
1950 sprintf(firsttile,"%d",0);
1951 //int32_t ret;
1952
1953
1954
1955 read_tiles_dlg[0].dp2 = get_zc_font(font_lfont);
1956
1957 sprintf(firsttile,"%d",0);
1958 //sprintf(tilecount,"%d",1);
1959
1960 read_tiles_dlg[5].dp = firsttile;
1961
1962 large_dialog(read_tiles_dlg);
1963
1964 int32_t ret = do_zqdialog(read_tiles_dlg,-1);
1965 jwin_center_dialog(read_tiles_dlg);
1966
1967 if(ret == 8)
1968 {
1969 first_tile_id = vbound(atoi(firsttile), 0, NEWMAXTILES);
1970 //the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
1971 if(getname("Load ZTILE(.ztile)", "ztile", NULL,datapath,false))
1972 {
1973
1974 char name[256];
1975 extract_name(temppath,name,FILENAMEALL);
1976 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
1977 if(f)
1978 {
1979
1980 if (!readtilefile_to_location(f,first_tile_id))
1981 {
1982 al_trace("Could not read from .ztile packfile %s\n", name);
1983 jwin_alert("ZTILE File: Error","Could not load the specified Tile.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
1984 }
1985 else
1986 {
1987 jwin_alert("ZTILE File: Success!","Loaded the source tiles to your tile sheets!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
1988 }
1989 pack_fclose(f);
1990 }
1991 }
1992 }
1993 }
1994
1995
1996 static DIALOG save_combofiles_dlg[] =
1997 {
1998 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
1999
2000
2001 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Save Combo Pack", NULL, NULL },
2002 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2003 //for future tabs
2004 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2005 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2006 //4
2007 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First", NULL, NULL },
2008 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2009 //6
2010 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2011 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2012 //8
2013 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Save", NULL, NULL },
2014 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2015 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2016 };
2017
2018
2019 void savesomecombos(const char *prompt,int32_t initialval)
2020 {
2021
2022 char firsttile[8], tilecount[8];
2023 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2024 sprintf(firsttile,"%d",0);
2025 sprintf(tilecount,"%d",1);
2026 //int32_t ret;
2027
2028
2029
2030 save_combofiles_dlg[0].dp2 = get_zc_font(font_lfont);
2031
2032 sprintf(firsttile,"%d",0);
2033 sprintf(tilecount,"%d",1);
2034
2035 save_combofiles_dlg[5].dp = firsttile;
2036 save_combofiles_dlg[7].dp = tilecount;
2037
2038 large_dialog(save_combofiles_dlg);
2039
2040 int32_t ret = do_zqdialog(save_combofiles_dlg,-1);
2041 jwin_center_dialog(save_combofiles_dlg);
2042
2043 if(ret == 8)
2044 {
2045 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOS-1));
2046 the_tile_count = vbound(atoi(tilecount), 1, (MAXCOMBOS-1)-first_tile_id);
2047 if(getname("Save ZCOMBO(.zcombo)", "zcombo", NULL,datapath,false))
2048 {
2049 char name[PATH_MAX];
2050 extract_name(temppath,name,FILENAMEALL);
2051 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
2052 if(f)
2053 {
2054 writecombofile(f,first_tile_id,the_tile_count);
2055 pack_fclose(f);
2056 char tmpbuf[PATH_MAX+20]={0};
2057 sprintf(tmpbuf,"Saved %s",name);
2058 jwin_alert("Success!",tmpbuf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2059 }
2060 }
2061 }
2062 }
2063
2064
2065 static DIALOG load_comboset_dlg[] =
2066 {
2067 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2068
2069
2070 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Combo Set (Range)", NULL, NULL },
2071 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2072 //for future tabs
2073 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2074 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2075 //4
2076 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First:", NULL, NULL },
2077 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2078 //6
2079 { d_dummy_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2080 { d_dummy_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2081 //8
2082 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
2083 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2084 { jwin_check_proc, 10, 46, 95, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Don't Overwrite", NULL, NULL },
2085
2086 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2087 };
2088
2089 void writesomecombos(const char *prompt,int32_t initialval)
2090 {
2091
2092 char firsttile[8];
2093 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2094 sprintf(firsttile,"%d",0);
2095 //int32_t ret;
2096
2097
2098
2099 load_comboset_dlg[0].dp2 = get_zc_font(font_lfont);
2100
2101 sprintf(firsttile,"%d",0);
2102 //sprintf(tilecount,"%d",1);
2103
2104 load_comboset_dlg[5].dp = firsttile;
2105
2106 byte nooverwrite = 0;
2107
2108
2109 large_dialog(load_comboset_dlg);
2110
2111 int32_t ret = do_zqdialog(load_comboset_dlg,-1);
2112 jwin_center_dialog(load_comboset_dlg);
2113
2114 if(ret == 8)
2115 {
2116 if (load_comboset_dlg[10].flags & D_SELECTED) nooverwrite = 1;
2117
2118 al_trace("Nooverwrite is: %d\n", nooverwrite);
2119 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOS-1));
2120 //the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
2121 if(getname("Load ZCOMBO(.zcombo)", "zcombo", NULL,datapath,false))
2122 {
2123 char name[256];
2124 extract_name(temppath,name,FILENAMEALL);
2125 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
2126 if(f)
2127 {
2128
2129 if (!readcombofile(f,first_tile_id,nooverwrite))
2130 {
2131 al_trace("Could not read from .zcombo packfile %s\n", name);
2132 jwin_alert("ZCOMBO File: Error","Could not load the specified combos.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2133 }
2134 else
2135 {
2136 jwin_alert("ZCOMBO File: Success!","Loaded the source combos to your combo pages!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2137 saved=false;
2138 }
2139 pack_fclose(f);
2140 }
2141
2142 }
2143 }
2144 }
2145
2146 static DIALOG load_combopack_dlg[] =
2147 {
2148 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2149
2150
2151 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Import Full Combo Package 1:1", NULL, NULL },
2152 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2153 //for future tabs
2154 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2155 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2156 //4
2157 { d_dummy_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Starting at:", NULL, NULL },
2158 { d_dummy_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2159 //6
2160 { d_dummy_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2161 { d_dummy_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2162 //8
2163 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
2164 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2165 { jwin_check_proc, 10, 42, 95, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Don't Overwrite", NULL, NULL },
2166
2167 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2168 };
2169
2170 void loadcombopack(const char *prompt,int32_t initialval)
2171 {
2172
2173 char firsttile[8];
2174 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2175 sprintf(firsttile,"%d",0);
2176 //int32_t ret;
2177
2178
2179
2180 load_combopack_dlg[0].dp2 = get_zc_font(font_lfont);
2181
2182 sprintf(firsttile,"%d",0);
2183 //sprintf(tilecount,"%d",1);
2184
2185 load_combopack_dlg[5].dp = firsttile;
2186
2187 byte nooverwrite = 0;
2188
2189
2190 large_dialog(load_combopack_dlg);
2191
2192 int32_t ret = do_zqdialog(load_combopack_dlg,-1);
2193 jwin_center_dialog(load_combopack_dlg);
2194
2195 if(ret == 8)
2196 {
2197 if (load_combopack_dlg[10].flags & D_SELECTED) nooverwrite = 1;
2198
2199 al_trace("Nooverwrite is: %d\n", nooverwrite);
2200 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOS-1));
2201 //the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
2202 if(getname("Load ZCOMBO(.zcombo)", "zcombo", NULL,datapath,false))
2203 {
2204 char name[256];
2205 extract_name(temppath,name,FILENAMEALL);
2206 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
2207 if(f)
2208 {
2209 //need dialogue here
2210 if (!readcombofile(f,0,nooverwrite))
2211 {
2212 al_trace("Could not read from .zcombo packfile %s\n", name);
2213 jwin_alert("ZCOMBO File: Error","Could not load the specified Tile.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2214 }
2215 else
2216 {
2217 jwin_alert("ZCOMBO File: Success!","Loaded the source combos to your combo pages!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2218 saved=false;
2219 }
2220 }
2221
2222 pack_fclose(f);
2223 }
2224 }
2225 }
2226
2227
2228 static DIALOG read_combopack_dlg[] =
2229 {
2230 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2231
2232
2233 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Load Combos (Specific Dest)", NULL, NULL },
2234 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2235 //for future tabs
2236 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2237 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2238 //4
2239 { jwin_text_proc, 10, 24, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Starting at:", NULL, NULL },
2240 { jwin_edit_proc, 55, 22, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2241 //6
2242 { d_dummy_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2243 { d_dummy_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2244 //8
2245 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
2246 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2247 //10
2248 { jwin_check_proc, 10, 58, 95, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Don't Overwrite", NULL, NULL },
2249 //11
2250 { jwin_text_proc, 10, 42, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Skip:", NULL, NULL },
2251 //12
2252 { jwin_edit_proc, 55, 40, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2253
2254 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2255 };
2256
2257
2258
2259 void writesomecombos_to(const char *prompt,int32_t initialval)
2260 {
2261
2262 char firsttile[8];
2263 char skiptile[8];
2264 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2265 sprintf(firsttile,"%d",0);
2266 //int32_t ret;
2267
2268
2269
2270 read_combopack_dlg[0].dp2 = get_zc_font(font_lfont);
2271
2272 sprintf(skiptile,"%d",0);
2273 //sprintf(tilecount,"%d",1);
2274
2275 read_combopack_dlg[5].dp = firsttile;
2276
2277 byte nooverwrite = 0;
2278 int32_t skipover = 0;
2279
2280 sprintf(skiptile,"%d",0);
2281 //sprintf(tilecount,"%d",1);
2282
2283 read_combopack_dlg[12].dp = skiptile;
2284
2285 large_dialog(read_combopack_dlg);
2286
2287 int32_t ret = do_zqdialog(read_combopack_dlg,-1);
2288 jwin_center_dialog(read_combopack_dlg);
2289
2290 if(ret == 8)
2291 {
2292 if (read_combopack_dlg[10].flags & D_SELECTED) nooverwrite = 1;
2293
2294 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOS-1));
2295 skipover = vbound(atoi(skiptile), 0, (MAXCOMBOS-1));
2296 al_trace("skipover is: %d\n", skipover);
2297 //skipover = vbound(skipover, 0, (MAXCOMBOS-1-skipover));
2298 //the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
2299 if(getname("Load ZCOMBO(.zcombo)", "zcombo", NULL,datapath,false))
2300 {
2301 char name[256];
2302 extract_name(temppath,name,FILENAMEALL);
2303 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
2304 if(f)
2305 {
2306
2307 if (!readcombofile_to_location(f,first_tile_id,nooverwrite, skipover))
2308 {
2309 al_trace("Could not read from .zcombo packfile %s\n", name);
2310 jwin_alert("ZCOMBO File: Error","Could not load the specified combos.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2311 }
2312 else
2313 {
2314 jwin_alert("ZCOMBO File: Success!","Loaded the source combos to your combo pages!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2315 saved=false;
2316 }
2317 pack_fclose(f);
2318 }
2319
2320 }
2321 }
2322 }
2323
2324
2325
2326 static DIALOG save_dmaps_dlg[] =
2327 {
2328 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2329
2330
2331 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Save DMaps (.zdmap)", NULL, NULL },
2332 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2333 //for future tabs
2334 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2335 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2336 //4
2337 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First", NULL, NULL },
2338 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2339 //6
2340 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Last", NULL, NULL },
2341 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2342 //8
2343 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Save", NULL, NULL },
2344 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2345 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2346 };
2347
2348
2349 void savesomedmaps(const char *prompt,int32_t initialval)
2350 {
2351
2352 char firstdmap[8], lastdmap[8];
2353 int32_t first_dmap_id = 0; int32_t last_dmap_id = 0;
2354 sprintf(firstdmap,"%d",0);
2355 sprintf(lastdmap,"%d",1);
2356 //int32_t ret;
2357
2358
2359
2360 save_dmaps_dlg[0].dp2 = get_zc_font(font_lfont);
2361
2362 sprintf(firstdmap,"%d",0);
2363 sprintf(lastdmap,"%d",0);
2364
2365 save_dmaps_dlg[5].dp = firstdmap;
2366 save_dmaps_dlg[7].dp = lastdmap;
2367
2368 large_dialog(save_dmaps_dlg);
2369
2370 int32_t ret = do_zqdialog(save_dmaps_dlg,-1);
2371 jwin_center_dialog(save_dmaps_dlg);
2372
2373 if(ret == 8)
2374 {
2375 first_dmap_id = vbound(atoi(firstdmap), 0, MAXDMAPS-1);
2376 last_dmap_id = vbound(atoi(lastdmap), 0, MAXDMAPS-1);
2377
2378 if ( last_dmap_id < first_dmap_id )
2379 {
2380 int32_t swap = last_dmap_id;
2381 last_dmap_id = first_dmap_id;
2382 first_dmap_id = swap;
2383 }
2384 if(!getname("Export DMaps (.zdmap)","zdmap",NULL,datapath,false))
2385
2386
2387 saved=false;
2388
2389 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
2390 if(f)
2391 {
2392 if(!writesomedmaps(f,first_dmap_id,last_dmap_id,MAXDMAPS))
2393 {
2394 char buf[PATH_MAX+20],name[PATH_MAX];
2395 extract_name(temppath,name,FILENAMEALL);
2396 sprintf(buf,"Unable to load %s",name);
2397 jwin_alert("Error",buf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2398 }
2399 else
2400 {
2401 char name[PATH_MAX];
2402 extract_name(temppath,name,FILENAMEALL);
2403 char tmpbuf[PATH_MAX+20]={0};
2404 sprintf(tmpbuf,"Saved %s",name);
2405 jwin_alert("Success!",tmpbuf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2406 }
2407 }
2408 pack_fclose(f);
2409 }
2410 }
2411
2412 static DIALOG save_comboaliasfiles_dlg[] =
2413 {
2414 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2415
2416
2417 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Save Combo Alias Pack", NULL, NULL },
2418 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2419 //for future tabs
2420 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2421 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2422 //4
2423 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First", NULL, NULL },
2424 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2425 //6
2426 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2427 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2428 //8
2429 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Save", NULL, NULL },
2430 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2431 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2432 };
2433
2434
2435 void savesomecomboaliases(const char *prompt,int32_t initialval)
2436 {
2437
2438 char firsttile[8], tilecount[8];
2439 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2440 sprintf(firsttile,"%d",0);
2441 sprintf(tilecount,"%d",1);
2442 //int32_t ret;
2443
2444
2445
2446 save_comboaliasfiles_dlg[0].dp2 = get_zc_font(font_lfont);
2447
2448 sprintf(firsttile,"%d",0);
2449 sprintf(tilecount,"%d",1);
2450
2451 save_comboaliasfiles_dlg[5].dp = firsttile;
2452 save_comboaliasfiles_dlg[7].dp = tilecount;
2453
2454 large_dialog(save_comboaliasfiles_dlg);
2455
2456 int32_t ret = do_zqdialog(save_comboaliasfiles_dlg,-1);
2457 jwin_center_dialog(save_comboaliasfiles_dlg);
2458
2459 if(ret == 8)
2460 {
2461 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOALIASES-1));
2462 the_tile_count = vbound(atoi(tilecount), 1, (MAXCOMBOALIASES-1)-first_tile_id);
2463 if(getname("Save ZALIAS(.zalias)", "zalias", NULL,datapath,false))
2464 {
2465 char name[PATH_MAX];
2466 extract_name(temppath,name,FILENAMEALL);
2467 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
2468 if(f)
2469 {
2470 writecomboaliasfile(f,first_tile_id,the_tile_count);
2471 pack_fclose(f);
2472 char tmpbuf[PATH_MAX+20]={0};
2473 sprintf(tmpbuf,"Saved %s",name);
2474 jwin_alert("Success!",tmpbuf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2475 }
2476 }
2477 }
2478 }
2479
2480
2481 static DIALOG read_comboaliaspack_dlg[] =
2482 {
2483 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2484
2485
2486 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Load Combo Pack To:", NULL, NULL },
2487 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2488 //for future tabs
2489 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2490 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2491 //4
2492 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Starting at:", NULL, NULL },
2493 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2494 //6
2495 { d_dummy_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2496 { d_dummy_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2497 //8
2498 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
2499 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2500 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2501 };
2502
2503
2504 void writesomecomboaliases_to(const char *prompt,int32_t initialval)
2505 {
2506
2507 char firsttile[8];;
2508 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2509 sprintf(firsttile,"%d",0);
2510 //int32_t ret;
2511
2512
2513
2514 read_comboaliaspack_dlg[0].dp2 = get_zc_font(font_lfont);
2515
2516 sprintf(firsttile,"%d",0);
2517 //sprintf(tilecount,"%d",1);
2518
2519 read_comboaliaspack_dlg[5].dp = firsttile;
2520
2521 large_dialog(read_comboaliaspack_dlg);
2522
2523 int32_t ret = do_zqdialog(read_comboaliaspack_dlg,-1);
2524 jwin_center_dialog(read_comboaliaspack_dlg);
2525
2526 if(ret == 8)
2527 {
2528 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOALIASES-1));
2529 //the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
2530 if(getname("Load ZALIAS(.zalias)", "zalias", NULL,datapath,false))
2531 {
2532 char name[256];
2533 extract_name(temppath,name,FILENAMEALL);
2534 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
2535 if(f)
2536 {
2537
2538 if (!readcomboaliasfile_to_location(f,first_tile_id))
2539 {
2540 al_trace("Could not read from .zcombo packfile %s\n", name);
2541 jwin_alert("ZALIAS File: Error","Could not load the specified combo aliases.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2542 }
2543 else
2544 {
2545 jwin_alert("ZALIAS File: Success!","Loaded the source combos to your combo alias table!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2546 saved=false;
2547 }
2548 pack_fclose(f);
2549 }
2550 }
2551 }
2552 }
2553
2554
2555
2556
2557 //Doorsets
2558
2559 static DIALOG save_doorset_dlg[] =
2560 {
2561 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2562 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Save Doorset", NULL, NULL },
2563 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2564 //for future tabs
2565 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2566 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2567 //4
2568 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First", NULL, NULL },
2569 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2570 //6
2571 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2572 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2573 //8
2574 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Save", NULL, NULL },
2575 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2576 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2577 };
2578
2579
2580 void do_exportdoorset(const char *prompt,int32_t initialval)
2581 {
2582 char firstdoor[8], doorct[8];
2583 int32_t first_doorset_id = 0; int32_t the_doorset_count = 1;
2584 sprintf(firstdoor,"%d",0);
2585 sprintf(doorct,"%d",1);
2586 //int32_t ret;
2587 save_doorset_dlg[0].dp2 = get_zc_font(font_lfont);
2588
2589 sprintf(firstdoor,"%d",0);
2590 sprintf(doorct,"%d",1);
2591
2592 save_doorset_dlg[5].dp = firstdoor;
2593 save_doorset_dlg[7].dp = doorct;
2594
2595 large_dialog(save_doorset_dlg);
2596
2597 int32_t ret = do_zqdialog(save_doorset_dlg,-1);
2598 jwin_center_dialog(save_doorset_dlg);
2599
2600 if(ret == 8) //OK
2601 {
2602 /* sanity bounds
2603 first_doorset_id = vbound(atoi(firstdoor), 0, (MAXCOMBOS-1));
2604 the_doorset_count = vbound(atoi(doorct), 1, (MAXCOMBOS-1)-first_doorset_id);
2605 */
2606 if(getname("Save ZDOORS(.zdoors)", "zdoors", NULL,datapath,false))
2607 {
2608 char name[256];
2609 extract_name(temppath,name,FILENAMEALL);
2610 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
2611 if(f)
2612 {
2613 writezdoorsets(f,first_doorset_id,the_doorset_count);
2614 pack_fclose(f);
2615 char tmpbuf[512]={0};
2616 sprintf(tmpbuf,"Saved %s",name);
2617 jwin_alert("Success!",tmpbuf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2618 }
2619 }
2620 }
2621 }
2622
2623 static DIALOG load_doorset_dlg[] =
2624 {
2625 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2626 { jwin_win_proc, 0, 0, 120, 124, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Door Set (Range)", NULL, NULL },
2627 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2628 //for future tabs
2629 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2630 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2631 //4
2632 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First:", NULL, NULL },
2633 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2634 //6
2635 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2636 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2637 //8
2638 { jwin_button_proc, 15, 92, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
2639 { jwin_button_proc, 69, 92, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2640 //10
2641 { jwin_text_proc, 10, 64, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Dest", NULL, NULL },
2642 { jwin_edit_proc, 55, 63, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2643 //8
2644
2645 // { jwin_check_proc, 10, 46, 95, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Don't Overwrite", NULL, NULL },
2646
2647 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2648 };
2649
2650 void do_importdoorset(const char *prompt,int32_t initialval)
2651 {
2652
2653 char firstdoor[8], doorct[8], destid[8];
2654 int32_t first_doorset_id = 0; int32_t the_doorset_count = 1;
2655 int32_t the_dest_id = 0;
2656 sprintf(firstdoor,"%d",0);
2657 sprintf(doorct,"%d",1);
2658 sprintf(destid,"%d",0);
2659 //int32_t ret;
2660
2661 save_doorset_dlg[0].dp2 = get_zc_font(font_lfont);
2662
2663 load_doorset_dlg[5].dp = firstdoor;
2664 load_doorset_dlg[7].dp = doorct;
2665 load_doorset_dlg[11].dp = destid;
2666
2667 byte nooverwrite = 0;
2668
2669 large_dialog(load_doorset_dlg);
2670
2671 int32_t ret = do_zqdialog(load_doorset_dlg,-1);
2672 jwin_center_dialog(load_doorset_dlg);
2673
2674 if(ret == 8) //OK
2675 {
2676 //if (load_doorset_dlg[10].flags & D_SELECTED) nooverwrite = 1;
2677
2678 //al_trace("Nooverwrite is: %d\n", nooverwrite);
2679 //sanity bound
2680 first_doorset_id = vbound(atoi(firstdoor), 0, door_combo_set_count);
2681 the_doorset_count = vbound(atoi(doorct), 1, door_combo_set_count);
2682 the_dest_id = vbound(atoi(destid), 0, door_combo_set_count);
2683 if(getname("Load ZDOORS(.zdoors)", "zdoors", NULL,datapath,false))
2684 {
2685 char name[256];
2686 extract_name(temppath,name,FILENAMEALL);
2687 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
2688 if(f)
2689 {
2690 int32_t ret = readzdoorsets(f,first_doorset_id,the_doorset_count, the_dest_id);
2691
2692 if (!ret)
2693 {
2694 al_trace("Could not read from .zdoors packfile %s\n", name);
2695 jwin_alert("ZDOORS File: Error","Could not load the specified doorsets.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2696 }
2697 else if ( ret == 1 )
2698 {
2699 jwin_alert("ZDOORS File: Success!","Loaded the source doorsets!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2700 saved=false;
2701 }
2702 else if ( ret == 2 )
2703 {
2704 jwin_alert("ZDOORS File: Issue:","Targets exceed doorset count!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2705 saved=false;
2706 }
2707 pack_fclose(f);
2708 }
2709 }
2710 }
2711 }
2712
2713 int32_t gettilepagenumber(const char *prompt, int32_t initialval)
2714 {
2715 char buf[20];
2716 sprintf(buf,"%d",initialval);
2717 getnum_dlg[0].dp=(void *)prompt;
2718 getnum_dlg[0].dp2=get_zc_font(font_lfont);
2719 getnum_dlg[2].dp=buf;
2720
2721 large_dialog(getnum_dlg);
2722
2723 int32_t ret = do_zqdialog(getnum_dlg,2);
2724
2725 if(ret==3)
2726 return atoi(buf);
2727
2728 return -1;
2729 }
2730
2731 int32_t gethexnumber(const char *prompt,int32_t initialval)
2732 {
2733 cancelgetnum=true;
2734 char buf[20];
2735 sprintf(buf,"%X",initialval);
2736 getnum_dlg[0].dp=(void *)prompt;
2737 getnum_dlg[0].dp2=get_zc_font(font_lfont);
2738 getnum_dlg[2].dp=(void *)buf;
2739
2740 large_dialog(getnum_dlg);
2741
2742 int32_t ret=do_zqdialog(getnum_dlg,2);
2743
2744 if(ret!=0&&ret!=4)
2745 {
2746 cancelgetnum=false;
2747 }
2748
2749 if(ret==3)
2750 return zc_xtoi(buf);
2751
2752 return initialval;
2753 }
2754
2755 void update_combo_cycling()
2756 {
2757 Map.update_combo_cycling();
2758 }
2759
2760 void update_freeform_combos()
2761 {
2762 Map.update_freeform_combos();
2763 }
2764
2765 bool layers_valid(mapscr *tempscr)
2766 {
2767 for(int32_t i=0; i<6; i++)
2768 {
2769 if(tempscr->layermap[i]>map_count)
2770 {
2771 return false;
2772 }
2773 }
2774
2775 return true;
2776 }
2777
2778 void fix_layers(mapscr *tempscr, bool showwarning)
2779 {
2780 char buf[80]="layers have been changed: ";
2781
2782 for(int32_t i=0; i<6; i++)
2783 {
2784 if(tempscr->layermap[i]>map_count)
2785 {
2786 strcat(buf, "%d ");
2787 sprintf(buf, buf, i+1);
2788 tempscr->layermap[i]=0;
2789 }
2790 }
2791
2792 if(showwarning)
2793 {
2794 jwin_alert("Invalid layers detected",
2795 "One or more layers on this screen used",
2796 "maps that do not exist. The settings of these",
2797 buf, "O&K", NULL, 'o', 0, get_zc_font(font_lfont));
2798 }
2799 }
2800
2801 /***********************/
2802 /*** dialog handlers ***/
2803 /***********************/
2804
2805 extern const char *colorlist(int32_t index, int32_t *list_size);
2806
2807 static char autobackup_str_buf[32];
2808 const char *autobackuplist(int32_t index, int32_t *list_size)
2809 {
2810 if(index>=0)
2811 {
2812 bound(index,0,10);
2813
2814 if(index==0)
2815 {
2816 sprintf(autobackup_str_buf,"Disabled");
2817 }
2818 else
2819 {
2820 sprintf(autobackup_str_buf,"%2d",index);
2821 }
2822
2823 return autobackup_str_buf;
2824 }
2825
2826 *list_size=11;
2827 return NULL;
2828 }
2829
2830 static char autosave_str_buf[32];
2831 const char *autosavelist(int32_t index, int32_t *list_size)
2832 {
2833 if(index>=0)
2834 {
2835 bound(index,0,10);
2836
2837 if(index==0)
2838 {
2839 sprintf(autosave_str_buf,"Disabled");
2840 }
2841 else
2842 {
2843 sprintf(autosave_str_buf,"%2d Minute%c",index,index>1?'s':0);
2844 }
2845
2846 return autosave_str_buf;
2847 }
2848
2849 *list_size=11;
2850 return NULL;
2851 }
2852
2853 const char *autosavelist2(int32_t index, int32_t *list_size)
2854 {
2855 if(index>=0)
2856 {
2857 bound(index,0,9);
2858 sprintf(autosave_str_buf,"%2d",index+1);
2859 return autosave_str_buf;
2860 }
2861
2862 *list_size=10;
2863 return NULL;
2864 }
2865
2866
2867 static int32_t options_1_list[] =
2868 {
2869 // dialog control number
2870 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, -1
2871 };
2872
2873 static int32_t options_2_list[] =
2874 {
2875 // dialog control number
2876 50, 51, -1
2877 };
2878
2879 static int32_t options_3_list[] =
2880 {
2881 // dialog control number
2882 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, -1
2883 };
2884 static int32_t options_4_list[] =
2885 {
2886 57, 58, 59, 60,
2887 -1
2888 };
2889
2890 static TABPANEL options_tabs[] =
2891 {
2892 // (text)
2893 { (char *)" 1 ", D_SELECTED, options_1_list, 0, NULL },
2894 { (char *)" 2 ", 0, options_2_list, 0, NULL },
2895 { (char *)" 3 ", 0, options_3_list, 0, NULL },
2896 { (char *)" 4 ", 0, options_4_list, 0, NULL },
2897 { NULL, 0, NULL, 0, NULL }
2898 };
2899
2900 8 static ListData autobackup_list(autobackuplist, &font);
2901 8 static ListData autosave_list(autosavelist, &font);
2902 8 static ListData autosave_list2(autosavelist2, &font);
2903 8 static ListData color_list(colorlist, &font);
2904 8 static ListData snapshotformat_list(snapshotformatlist, &font);
2905 void init_ffpos();
2906
2907 void call_options_dlg();
2908 int32_t onOptions()
2909 {
2910 call_options_dlg();
2911 return D_O_K;
2912 }
2913
2914 const char *dm_names[dm_max]=
2915 {
2916 "Normal",
2917 "Relational",
2918 "Dungeon",
2919 "Alias",
2920 "Pool",
2921 "Auto"
2922 };
2923
2924 byte relational_tile_grid[11+(rtgyo*2)][16+(rtgxo*2)];
2925
2926 void fix_drawing_mode_menu()
2927 {
2928 drawing_mode_menu.select_only_uid(draw_mode);
2929 }
2930
2931 void reset_relational_tile_grid()
2932 {
2933 memset(relational_tile_grid,(draw_mode==dm_relational?1:0),(11+(rtgyo*2))*(16+(rtgxo*2)));
2934 }
2935
2936 int32_t onDrawingMode()
2937 {
2938 draw_mode=(draw_mode+1)%dm_max;
2939 if (draw_mode == dm_relational)
2940 draw_mode += 2;
2941 reset_relational_tile_grid();
2942 fix_drawing_mode_menu();
2943 restore_mouse();
2944 return D_O_K;
2945 }
2946
2947 int32_t onDrawingModeNormal()
2948 {
2949 draw_mode=dm_normal;
2950 reset_relational_tile_grid();
2951 fix_drawing_mode_menu();
2952 restore_mouse();
2953 return D_O_K;
2954 }
2955
2956 int32_t onDrawingModeRelational()
2957 {
2958 if(draw_mode==dm_relational)
2959 {
2960 return onDrawingModeNormal();
2961 }
2962
2963 draw_mode=dm_relational;
2964 reset_relational_tile_grid();
2965 fix_drawing_mode_menu();
2966 restore_mouse();
2967 return D_O_K;
2968 }
2969
2970 int32_t onDrawingModeDungeon()
2971 {
2972 if(draw_mode==dm_dungeon)
2973 {
2974 return onDrawingModeNormal();
2975 }
2976
2977 draw_mode=dm_dungeon;
2978 reset_relational_tile_grid();
2979 fix_drawing_mode_menu();
2980 restore_mouse();
2981 return D_O_K;
2982 }
2983
2984 int32_t onDrawingModeAlias()
2985 {
2986 if(draw_mode==dm_alias)
2987 {
2988 return onDrawingModeNormal();
2989 }
2990
2991 draw_mode=dm_alias;
2992 alias_cset_mod=0;
2993 reset_relational_tile_grid();
2994 fix_drawing_mode_menu();
2995 restore_mouse();
2996 return D_O_K;
2997 }
2998
2999 int32_t onDrawingModePool()
3000 {
3001 if(draw_mode==dm_cpool)
3002 {
3003 return onDrawingModeNormal();
3004 }
3005
3006 draw_mode=dm_cpool;
3007 reset_relational_tile_grid();
3008 fix_drawing_mode_menu();
3009 restore_mouse();
3010 return D_O_K;
3011 }
3012
3013 int32_t onDrawingModeAuto()
3014 {
3015 if (draw_mode == dm_auto)
3016 {
3017 return onDrawingModeNormal();
3018 }
3019
3020 draw_mode = dm_auto;
3021 reset_relational_tile_grid();
3022 fix_drawing_mode_menu();
3023 restore_mouse();
3024 return D_O_K;
3025 }
3026
3027 int32_t onReTemplate()
3028 {
3029 if(jwin_alert("Confirm Overwrite","Apply NES Dungeon template to","all screens on this map?",NULL,"&Yes","&No",'y','n',get_zc_font(font_lfont))==1)
3030 {
3031 Map.TemplateAll();
3032 refresh(rALL);
3033 }
3034
3035 return D_O_K;
3036 }
3037
3038 int32_t onUndo()
3039 {
3040 Map.UndoCommand();
3041 refresh(rALL);
3042 return D_O_K;
3043 }
3044
3045 int32_t onRedo()
3046 {
3047 Map.RedoCommand();
3048 refresh(rALL);
3049 return D_O_K;
3050 }
3051
3052 int32_t onCopy()
3053 {
3054 if(prv_mode)
3055 {
3056 Map.set_prvcmb(Map.get_prvcmb()==0?1:0);
3057
3058 init_ffpos();
3059
3060 return D_O_K;
3061 }
3062
3063 Map.Copy();
3064 return D_O_K;
3065 }
3066
3067 int32_t onPaste()
3068 {
3069 if(key[KEY_LSHIFT] || key[KEY_RSHIFT])
3070 {
3071 if(CHECK_CTRL_CMD)
3072 return onPasteAllToAll();
3073 else return onPasteAll();
3074 }
3075 else if(CHECK_CTRL_CMD)
3076 return onPasteToAll();
3077 else
3078 {
3079 Map.DoPasteScreenCommand(PasteCommandType::ScreenPartial);
3080 }
3081 return D_O_K;
3082 }
3083
3084 int32_t onPasteAll()
3085 {
3086 Map.DoPasteScreenCommand(PasteCommandType::ScreenAll);
3087 return D_O_K;
3088 }
3089
3090 int32_t onPasteToAll()
3091 {
3092 if(confirmBox("You are about to paste to all screens on the current map."))
3093 {
3094 Map.DoPasteScreenCommand(PasteCommandType::ScreenPartialToEveryScreen);
3095 }
3096 return D_O_K;
3097 }
3098
3099 int32_t onPasteAllToAll()
3100 {
3101 if(confirmBox("You are about to paste to all screens on the current map."))
3102 {
3103 Map.DoPasteScreenCommand(PasteCommandType::ScreenAllToEveryScreen);
3104 }
3105 return D_O_K;
3106 }
3107
3108 int32_t onPasteUnderCombo()
3109 {
3110 Map.DoPasteScreenCommand(PasteCommandType::ScreenUnderCombo);
3111 return D_O_K;
3112 }
3113
3114 int32_t onPasteSecretCombos()
3115 {
3116 Map.DoPasteScreenCommand(PasteCommandType::ScreenSecretCombos);
3117 return D_O_K;
3118 }
3119
3120 int32_t onPasteFFCombos()
3121 {
3122 Map.DoPasteScreenCommand(PasteCommandType::ScreenFFCombos);
3123 return D_O_K;
3124 }
3125
3126 int32_t onPasteWarps()
3127 {
3128 Map.DoPasteScreenCommand(PasteCommandType::ScreenWarps);
3129 return D_O_K;
3130 }
3131
3132 int32_t onPasteScreenData()
3133 {
3134 Map.DoPasteScreenCommand(PasteCommandType::ScreenData);
3135 return D_O_K;
3136 }
3137
3138 int32_t onPasteWarpLocations()
3139 {
3140 Map.DoPasteScreenCommand(PasteCommandType::ScreenWarpLocations);
3141 return D_O_K;
3142 }
3143
3144 int32_t onPasteDoors()
3145 {
3146 Map.DoPasteScreenCommand(PasteCommandType::ScreenDoors);
3147 return D_O_K;
3148 }
3149
3150 int32_t onPasteLayers()
3151 {
3152 Map.DoPasteScreenCommand(PasteCommandType::ScreenLayers);
3153 return D_O_K;
3154 }
3155
3156 int32_t onPastePalette()
3157 {
3158 Map.DoPasteScreenCommand(PasteCommandType::ScreenPalette);
3159 return D_O_K;
3160 }
3161
3162 int32_t onPasteRoom()
3163 {
3164 Map.DoPasteScreenCommand(PasteCommandType::ScreenRoom);
3165 return D_O_K;
3166 }
3167
3168 int32_t onPasteGuy()
3169 {
3170 Map.DoPasteScreenCommand(PasteCommandType::ScreenGuy);
3171 return D_O_K;
3172 }
3173
3174 int32_t onPasteEnemies()
3175 {
3176 Map.DoPasteScreenCommand(PasteCommandType::ScreenEnemies);
3177 return D_O_K;
3178 }
3179
3180 int32_t onDelete()
3181 {
3182 restore_mouse();
3183
3184 if(!(Map.CurrScr()->valid&mVALID) || jwin_alert("Confirm Delete","Delete this screen?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3185 {
3186 Map.DoClearScreenCommand();
3187 }
3188
3189 reset_relational_tile_grid();
3190 saved=false;
3191 return D_O_K;
3192 }
3193
3194 int32_t onDeleteMap()
3195 {
3196 if(jwin_alert("Confirm Delete","Clear this entire map?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3197 {
3198 Map.clearmap(false);
3199 refresh(rALL);
3200 saved=false;
3201 }
3202
3203 return D_O_K;
3204 }
3205
3206 int32_t onToggleDarkness()
3207 {
3208 Map.CurrScr()->flags^=4;
3209 refresh(rMAP+rMENU);
3210 saved=false;
3211 return D_O_K;
3212 }
3213
3214 int32_t onIncMap()
3215 {
3216 int32_t m=Map.getCurrMap();
3217 int32_t oldcolor=Map.getcolor();
3218 Map.setCurrMap(m+1>=map_count?0:m+1);
3219 Map.setCurrScr(Map.getCurrScr()); //Needed to refresh the screen info. -Z ( 26th March, 2019 )
3220 Map.setlayertarget(); //Needed to refresh the screen info. -Z ( 26th March, 2019 )
3221 if(m!=Map.getCurrMap())
3222 {
3223 reset_relational_tile_grid();
3224 }
3225
3226 int32_t newcolor=Map.getcolor();
3227
3228 if(newcolor!=oldcolor)
3229 {
3230 rebuild_trans_table();
3231 }
3232
3233 refresh(rALL);
3234 return D_O_K;
3235 }
3236
3237 int32_t onDecMap()
3238 {
3239 int32_t m=Map.getCurrMap();
3240 int32_t oldcolor=Map.getcolor();
3241 Map.setCurrMap((m-1<0)?map_count-1:zc_min(m-1,map_count-1));
3242 Map.setCurrScr(Map.getCurrScr()); //Needed to refresh the screen info. -Z ( 26th March, 2019 )
3243 Map.setlayertarget(); //Needed to refresh the screen info. -Z ( 26th March, 2019 )
3244
3245 if(m!=Map.getCurrMap())
3246 {
3247 reset_relational_tile_grid();
3248 }
3249
3250 int32_t newcolor=Map.getcolor();
3251
3252 if(newcolor!=oldcolor)
3253 {
3254 rebuild_trans_table();
3255 }
3256
3257 refresh(rALL);
3258 return D_O_K;
3259 }
3260
3261
3262 int32_t onDefault_Pals()
3263 {
3264 if(jwin_alert("Confirm Reset","Reset all palette data?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3265 {
3266 saved=false;
3267
3268 if(!init_colordata(true, &header, &QMisc))
3269 {
3270 jwin_alert("Error","Palette reset failed.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
3271 }
3272
3273 refresh_pal();
3274 }
3275
3276 return D_O_K;
3277 }
3278
3279 int32_t onDefault_Combos()
3280 {
3281 if(jwin_alert("Confirm Reset","Reset combo data?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3282 {
3283 saved=false;
3284
3285 if(!init_combos(true, &header))
3286 {
3287 jwin_alert("Error","Combo reset failed.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
3288 }
3289
3290 refresh(rALL);
3291 }
3292
3293 return D_O_K;
3294 }
3295
3296 int32_t onDefault_Items()
3297 {
3298 if(jwin_alert("Confirm Reset","Reset all items?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3299 {
3300 saved=false;
3301 reset_items(true, &header);
3302 }
3303
3304 return D_O_K;
3305 }
3306
3307 int32_t onDefault_Weapons()
3308 {
3309 if(jwin_alert("Confirm Reset","Reset weapon/misc. sprite data?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3310 {
3311 saved=false;
3312 reset_wpns(true, &header);
3313 }
3314
3315 return D_O_K;
3316 }
3317
3318 int32_t onDefault_Guys()
3319 {
3320 if(jwin_alert("Confirm Reset","Reset all enemy/NPC data?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3321 {
3322 saved=false;
3323 reset_guys();
3324 }
3325
3326 return D_O_K;
3327 }
3328
3329
3330 int32_t onDefault_Tiles()
3331 {
3332 if(jwin_alert("Confirm Reset","Reset all tiles?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3333 {
3334 saved=false;
3335
3336 if(!init_tiles(true, &header))
3337 {
3338 jwin_alert("Error","Tile reset failed.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
3339 }
3340
3341 refresh(rALL);
3342 }
3343
3344 return D_O_K;
3345 }
3346
3347 void change_sfx(SAMPLE *sfx1, SAMPLE *sfx2);
3348
3349 int32_t onDefault_SFX()
3350 {
3351 if(jwin_alert("Confirm Reset","Reset all sound effects?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3352 {
3353 saved=false;
3354 SAMPLE *temp_sample;
3355
3356 for(int32_t i=1; i<WAV_COUNT; i++)
3357 {
3358 temp_sample = (SAMPLE *)sfxdata[zc_min(i,Z35)].dat;
3359 change_sfx(&customsfxdata[i], temp_sample);
3360 sprintf(sfx_string[i],"s%03d",i);
3361
3362 if(i<Z35)
3363 strcpy(sfx_string[i], old_sfx_string[i-1]);
3364 set_bit(customsfxflag, i<Z35?1:0, i-1);
3365 }
3366 }
3367
3368 return D_O_K;
3369 }
3370
3371
3372 int32_t onDefault_MapStyles()
3373 {
3374 if(jwin_alert("Confirm Reset","Reset all map styles?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3375 {
3376 saved=false;
3377 reset_mapstyles(true, &QMisc);
3378 }
3379
3380 return D_O_K;
3381 }
3382
3383 int onScrollScreen(int dir, bool warp)
3384 {
3385 Map.scroll(dir,warp);
3386 return D_O_K;
3387 }
3388
3389 int32_t onComboColLeft()
3390 {
3391 if(draw_mode==dm_cpool||draw_mode==dm_auto)
3392 ;
3393 else if((First[current_combolist]>0)&&(draw_mode!=dm_alias))
3394 {
3395 First[current_combolist]-=1;
3396 clear_tooltip();
3397 refresh(rCOMBOS);
3398 }
3399 else if((combo_alistpos[current_comboalist]>0)&&(draw_mode==dm_alias))
3400 {
3401 combo_alistpos[current_comboalist]-=1;
3402 clear_tooltip();
3403 refresh(rCOMBOS);
3404 }
3405
3406 clear_keybuf();
3407 return D_O_K;
3408 }
3409
3410 int32_t onComboColRight()
3411 {
3412 auto& sqr = (draw_mode == dm_alias ? comboaliaslist[current_comboalist] : combolist[current_combolist]);
3413 if(draw_mode==dm_cpool||draw_mode==dm_auto)
3414 ;
3415 else if((First[current_combolist]<(MAXCOMBOS-(sqr.w*sqr.h)))&&(draw_mode!=dm_alias))
3416 {
3417 First[current_combolist]+=1;
3418 clear_tooltip();
3419 refresh(rCOMBOS);
3420 }
3421 else if((combo_alistpos[current_comboalist]<(MAXCOMBOALIASES-(sqr.w*sqr.h)))&&(draw_mode==dm_alias))
3422 {
3423 combo_alistpos[current_comboalist]+=1;
3424 clear_tooltip();
3425 refresh(rCOMBOS);
3426 }
3427
3428 clear_keybuf();
3429 return D_O_K;
3430 }
3431
3432 int32_t onComboColUp()
3433 {
3434 auto& sqr = (draw_mode == dm_alias ? comboaliaslist[current_comboalist] : combolist[current_combolist]);
3435 if(draw_mode==dm_cpool||draw_mode==dm_auto)
3436 ;
3437 else if((First[current_combolist]>0)&&(draw_mode!=dm_alias))
3438 {
3439 First[current_combolist]-=zc_min(First[current_combolist],sqr.w);
3440 clear_tooltip();
3441
3442 refresh(rCOMBOS);
3443 }
3444 else if((combo_alistpos[current_comboalist]>0)&&(draw_mode==dm_alias))
3445 {
3446 combo_alistpos[current_comboalist]-=zc_min(combo_alistpos[current_comboalist],sqr.w);
3447 clear_tooltip();
3448 refresh(rCOMBOS);
3449 }
3450
3451 clear_keybuf();
3452 return D_O_K;
3453 }
3454
3455 int32_t onComboColDown()
3456 {
3457 auto& sqr = (draw_mode == dm_alias ? comboaliaslist[current_comboalist] : combolist[current_combolist]);
3458
3459 if(draw_mode==dm_cpool||draw_mode==dm_auto)
3460 ;
3461 else if((First[current_combolist]<(MAXCOMBOS-(sqr.w*sqr.h)))&&(draw_mode!=dm_alias))
3462 {
3463 First[current_combolist]+=zc_min((MAXCOMBOS-sqr.w)-First[current_combolist],sqr.w);
3464 clear_tooltip();
3465 refresh(rCOMBOS);
3466 }
3467 else if((combo_alistpos[current_comboalist]<(MAXCOMBOALIASES-(comboaliaslist[0].w*comboaliaslist[0].h)))&&(draw_mode==dm_alias))
3468 {
3469 combo_alistpos[current_comboalist]+=zc_min((MAXCOMBOALIASES-sqr.w)-combo_alistpos[current_comboalist],sqr.w);
3470 clear_tooltip();
3471 refresh(rCOMBOS);
3472 }
3473
3474 clear_keybuf();
3475 return D_O_K;
3476 }
3477
3478 void scrollup(int j)
3479 {
3480 switch(draw_mode)
3481 {
3482 case dm_alias:
3483 {
3484 auto& sqr = comboaliaslist[j];
3485 if(combo_alistpos[j]>0)
3486 {
3487 if(CHECK_CTRL_CMD)
3488 {
3489 combo_alistpos[j]=0;
3490 clear_tooltip();
3491 }
3492 else
3493 {
3494 combo_alistpos[j]-=zc_min(combo_alistpos[j],(sqr.w*sqr.h));
3495 clear_tooltip();
3496 }
3497
3498 refresh(rCOMBOS);
3499 }
3500 break;
3501 }
3502 case dm_cpool:
3503 {
3504 auto& sqr = comboaliaslist[j];
3505 if(combo_pool_listpos[j]>0)
3506 {
3507 if(CHECK_CTRL_CMD)
3508 {
3509 combo_pool_listpos[j]=0;
3510 clear_tooltip();
3511 }
3512 else
3513 {
3514 combo_pool_listpos[j]-=zc_min(combo_pool_listpos[j],(sqr.w*sqr.h));
3515 clear_tooltip();
3516 }
3517
3518 refresh(rCOMBOS);
3519 }
3520 break;
3521 }
3522 case dm_auto:
3523 {
3524 auto& sqr = comboaliaslist[j];
3525 if (combo_auto_listpos[j] > 0)
3526 {
3527 if (CHECK_CTRL_CMD)
3528 {
3529 combo_auto_listpos[j] = 0;
3530 clear_tooltip();
3531 }
3532 else
3533 {
3534 combo_auto_listpos[j] -= zc_min(combo_auto_listpos[j], (sqr.w * sqr.h));
3535 clear_tooltip();
3536 }
3537
3538 refresh(rCOMBOS);
3539 }
3540 break;
3541 }
3542 default:
3543 {
3544 auto& sqr = combolist[j];
3545 if(First[j]>0)
3546 {
3547 if(CHECK_CTRL_CMD)
3548 {
3549 First[j]-=zc_min(First[j],256);
3550 clear_tooltip();
3551 }
3552 else
3553 {
3554 First[j]-=zc_min(First[j],(sqr.w*sqr.h));
3555 clear_tooltip();
3556 }
3557
3558 refresh(rCOMBOS);
3559 }
3560 break;
3561 }
3562 }
3563 }
3564 void scrolldown(int j)
3565 {
3566 switch(draw_mode)
3567 {
3568 case dm_alias:
3569 {
3570 auto& sqr = comboaliaslist[j];
3571 if(combo_alistpos[j]<(MAXCOMBOALIASES-(sqr.w*sqr.h)))
3572 {
3573 if(CHECK_CTRL_CMD)
3574 {
3575 combo_alistpos[j]=MAXCOMBOALIASES-(sqr.w*sqr.h);
3576 clear_tooltip();
3577 }
3578 else
3579 {
3580 combo_alistpos[j]=zc_min((MAXCOMBOALIASES-(sqr.w*sqr.h)),combo_alistpos[j]+(sqr.w*sqr.h));
3581 clear_tooltip();
3582 }
3583
3584 refresh(rCOMBOS);
3585 }
3586 break;
3587 }
3588 case dm_cpool:
3589 {
3590 auto& sqr = comboaliaslist[j];
3591 if(combo_pool_listpos[j]<(MAXCOMBOALIASES-(sqr.w*sqr.h)))
3592 {
3593 if(CHECK_CTRL_CMD)
3594 {
3595 combo_pool_listpos[j]=MAXCOMBOALIASES-(sqr.w*sqr.h);
3596 clear_tooltip();
3597 }
3598 else
3599 {
3600 combo_pool_listpos[j]=zc_min((MAXCOMBOALIASES-(sqr.w*sqr.h)),combo_pool_listpos[j]+(sqr.w*sqr.h));
3601 clear_tooltip();
3602 }
3603
3604 refresh(rCOMBOS);
3605 }
3606 break;
3607 }
3608 case dm_auto:
3609 {
3610 auto& sqr = comboaliaslist[j];
3611 if (combo_auto_listpos[j] < (MAXCOMBOALIASES - (sqr.w * sqr.h)))
3612 {
3613 if (CHECK_CTRL_CMD)
3614 {
3615 combo_auto_listpos[j] = MAXCOMBOALIASES - (sqr.w * sqr.h);
3616 clear_tooltip();
3617 }
3618 else
3619 {
3620 combo_auto_listpos[j] = zc_min((MAXCOMBOALIASES - (sqr.w * sqr.h)), combo_pool_listpos[j] + (sqr.w * sqr.h));
3621 clear_tooltip();
3622 }
3623
3624 refresh(rCOMBOS);
3625 }
3626 break;
3627 }
3628 default:
3629 {
3630 auto& sqr = combolist[j];
3631 if(First[j]<(MAXCOMBOS-(sqr.w*sqr.h)))
3632 {
3633 if(CHECK_CTRL_CMD)
3634 {
3635 First[j]=zc_min((MAXCOMBOS-sqr.w*sqr.h),First[j]+256);
3636 clear_tooltip();
3637 }
3638 else
3639 {
3640 First[j]=zc_min((MAXCOMBOS-(sqr.w*sqr.h)),First[j]+(sqr.w*sqr.h));
3641 clear_tooltip();
3642 }
3643
3644 refresh(rCOMBOS);
3645 }
3646 break;
3647 }
3648 }
3649 }
3650
3651 int32_t onPgUp()
3652 {
3653 switch(draw_mode)
3654 {
3655 case dm_alias:
3656 scrollup(current_comboalist);
3657 break;
3658 case dm_cpool:
3659 scrollup(current_cpoollist);
3660 break;
3661 case dm_auto:
3662 scrollup(current_cautolist);
3663 break;
3664 default:
3665 scrollup(current_combolist);
3666 break;
3667 }
3668 return D_O_K;
3669 }
3670
3671 int32_t onPgDn()
3672 {
3673 switch(draw_mode)
3674 {
3675 case dm_alias:
3676 scrolldown(current_comboalist);
3677 break;
3678 case dm_cpool:
3679 scrolldown(current_cpoollist);
3680 break;
3681 case dm_auto:
3682 scrolldown(current_cautolist);
3683 break;
3684 default:
3685 scrolldown(current_combolist);
3686 break;
3687 }
3688 return D_O_K;
3689 }
3690
3691 int32_t onIncreaseCSet()
3692 {
3693 if(draw_mode!=dm_alias)
3694 {
3695 CSet=wrap(CSet+1,0,13);
3696 refresh(rCOMBOS+rMENU+rCOMBO);
3697 }
3698 else
3699 {
3700 alias_cset_mod=wrap(alias_cset_mod+1,0,13);
3701 }
3702 return D_O_K;
3703 }
3704
3705 int32_t onDecreaseCSet()
3706 {
3707 if(draw_mode!=dm_alias)
3708 {
3709 CSet=wrap(CSet-1,0,13);
3710 refresh(rCOMBOS+rMENU+rCOMBO);
3711 }
3712 else
3713 {
3714 alias_cset_mod=wrap(alias_cset_mod-1,0,13);
3715 }
3716 return D_O_K;
3717 }
3718
3719 int32_t onGotoPage()
3720 {
3721 if (draw_mode==dm_alias)
3722 {
3723 static const int PER_PAGE = 260;
3724 if(optional<int> v = call_get_num("Scroll to Alias Page", 0, MAXCOMBOALIASES/PER_PAGE-1, 0))
3725 combo_alistpos[current_comboalist] = *v*PER_PAGE;
3726 }
3727 else if (draw_mode==dm_cpool)
3728 {
3729 static const int PER_PAGE = 260;
3730 if(optional<int> v = call_get_num("Scroll to Combo Pool Page", 0, MAXCOMBOPOOLS/PER_PAGE-1, 0))
3731 combo_pool_listpos[current_cpoollist] = *v*PER_PAGE;
3732 }
3733 else if (draw_mode == dm_auto)
3734 {
3735 static const int PER_PAGE = 260;
3736 if(optional<int> v = call_get_num("Scroll to Auto Combo Page", 0, MAXAUTOCOMBOS/PER_PAGE-1, 0))
3737 combo_auto_listpos[current_cautolist] = *v*PER_PAGE;
3738 }
3739 else
3740 {
3741 static const int PER_PAGE = 256;
3742 if(optional<int> v = call_get_num("Scroll to Combo Page", 0, MAXCOMBOS/PER_PAGE-1, 0))
3743 First[current_combolist] = *v*PER_PAGE;
3744 }
3745
3746 return D_O_K;
3747 }
3748
3749 bool getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
3750 {
3751 go();
3752 int32_t ret=0;
3753 ret = getname_nogo(prompt,ext,list,def,usefilename);
3754 comeback();
3755 return ret != 0;
3756 }
3757
3758
3759 bool getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
3760 {
3761 if(def!=temppath)
3762 strcpy(temppath,def);
3763
3764 if(!usefilename)
3765 {
3766 int32_t i=(int32_t)strlen(temppath);
3767
3768 while(i>=0 && temppath[i]!='\\' && temppath[i]!='/')
3769 temppath[i--]=0;
3770 }
3771
3772 // int32_t ret = file_select_ex(prompt,temppath,ext,255,-1,-1);
3773 int32_t ret=0;
3774 int32_t sel=0;
3775
3776 if(list==NULL)
3777 {
3778 ret = jwin_file_select_ex(prompt,temppath,ext,2048,-1,-1,get_zc_font(font_lfont));
3779 }
3780 else
3781 {
3782 ret = jwin_file_browse_ex(prompt, temppath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
3783 }
3784
3785 return ret!=0;
3786 }
3787
3788
3789 static char track_number_str_buf[MIDI_TRACK_BUFFER_SIZE] = {0};
3790 const char *tracknumlist(int32_t index, int32_t *list_size)
3791 {
3792 //memset(track_number_str_buf,0,50);
3793 if(index>=0)
3794 {
3795 bound(index,0,255);
3796 std::string name = zcmusic_get_track_name(zcmusic, index);
3797 sprintf(track_number_str_buf,"%02d %s",index+1, name.c_str());
3798 return track_number_str_buf;
3799 }
3800
3801 *list_size=zcmusic_get_tracks(zcmusic);
3802 return NULL;
3803 }
3804
3805 8 static ListData tracknum_list(tracknumlist, &font);
3806
3807 static DIALOG change_track_dlg[] =
3808 {
3809 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
3810 8 { jwin_win_proc, 60-12, 40, 200-16, 72, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Select Track", NULL, NULL },
3811 8 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
3812 8 { jwin_droplist_proc, 72-12, 60+4, 161, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &tracknum_list, NULL, NULL },
3813 8 { jwin_button_proc, 70, 87, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
3814 8 { jwin_button_proc, 150, 87, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
3815 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
3816 };
3817 // return list_dlg[2].d1;
3818
3819 int32_t changeTrack()
3820 {
3821 restore_mouse();
3822 change_track_dlg[0].dp2=get_zc_font(font_lfont);
3823 change_track_dlg[2].d1=gme_track;
3824
3825 large_dialog(change_track_dlg);
3826
3827 if(do_zqdialog(change_track_dlg,2)==3)
3828 {
3829 gme_track=change_track_dlg[2].d1;
3830 zcmusic_change_track(zcmusic, gme_track);
3831 }
3832
3833 return D_O_K;
3834 }
3835
3836 void set_media_tunes()
3837 {
3838 media_menu.select_uid(MENUID_MEDIA_TUNES, true);
3839 media_menu.select_uid(MENUID_MEDIA_PLAYMUSIC, false);
3840 disable_hotkey(ZQKEY_AMBIENT_MUSIC, false);
3841 disable_hotkey(ZQKEY_PLAY_MUSIC, false);
3842
3843 media_menu.disable_uid(MENUID_MEDIA_CHANGETRACK, true);
3844 disable_hotkey(ZQKEY_CHANGE_TRACK, true);
3845 }
3846
3847 int32_t playMusic()
3848 {
3849 char *ext;
3850 bool ismidi=false;
3851 char allmusic_types[256];
3852 sprintf(allmusic_types, "%s;mid", zcmusic_types);
3853
3854 if(getname("Load Music",(char*)allmusic_types,NULL,midipath,false))
3855 {
3856 strcpy(midipath,temppath);
3857
3858 ext=get_extension(midipath);
3859
3860 if(
3861 (stricmp(ext,"ogg")==0)||
3862 (stricmp(ext,"mp3")==0)||
3863 (stricmp(ext,"it")==0)||
3864 (stricmp(ext,"xm")==0)||
3865 (stricmp(ext,"s3m")==0)||
3866 (stricmp(ext,"mod")==0)||
3867 (stricmp(ext,"spc")==0)||
3868 (stricmp(ext,"gym")==0)||
3869 (stricmp(ext,"nsf")==0)||
3870 (stricmp(ext,"gbs")==0)||
3871 (stricmp(ext,"vgm")==0)
3872 )
3873 {
3874 ismidi=false;
3875 }
3876 else if((stricmp(ext,"mid")==0))
3877 {
3878 ismidi=true;
3879 }
3880 else
3881 {
3882 return D_O_K;
3883 }
3884
3885 zc_stop_midi();
3886
3887 if(zcmusic != NULL)
3888 {
3889 zcmusic_stop(zcmusic);
3890 zcmusic_unload_file(zcmusic);
3891 zcmusic = NULL;
3892 zcmixer->newtrack = NULL;
3893 }
3894
3895 if(ismidi)
3896 {
3897 packfile_password("");
3898 if((song=load_midi(midipath))!=NULL)
3899 {
3900 if(zc_play_midi(song,true)==0)
3901 {
3902 media_menu.select_uid(MENUID_MEDIA_TUNES, false);
3903 media_menu.select_uid(MENUID_MEDIA_PLAYMUSIC, true);
3904 disable_hotkey(ZQKEY_AMBIENT_MUSIC, false);
3905 disable_hotkey(ZQKEY_PLAY_MUSIC, false);
3906
3907 media_menu.disable_uid(MENUID_MEDIA_CHANGETRACK, true);
3908 disable_hotkey(ZQKEY_CHANGE_TRACK, true);
3909 }
3910 }
3911 }
3912 else
3913 {
3914 gme_track=0;
3915 zcmusic = (ZCMUSIC*)zcmusic_load_file(midipath);
3916
3917 if(zcmusic!=NULL)
3918 {
3919 media_menu.select_uid(MENUID_MEDIA_TUNES, false);
3920 media_menu.select_uid(MENUID_MEDIA_PLAYMUSIC, true);
3921 disable_hotkey(ZQKEY_AMBIENT_MUSIC, false);
3922 disable_hotkey(ZQKEY_PLAY_MUSIC, false);
3923
3924 bool distrack = zcmusic_get_tracks(zcmusic)<2;
3925 media_menu.disable_uid(MENUID_MEDIA_CHANGETRACK, distrack);
3926 disable_hotkey(ZQKEY_CHANGE_TRACK, distrack);
3927
3928 zcmusic_play(zcmusic, midi_volume);
3929 }
3930 }
3931 }
3932
3933 return D_O_K;
3934 }
3935
3936 int32_t playZCForever()
3937 {
3938 stopMusic();
3939
3940 zcmusic = zcmusic_load_file("assets/zc/ZC_Forever_HD.mp3");
3941 if (zcmusic)
3942 {
3943 zcmusic_play(zcmusic, midi_volume);
3944 set_media_tunes();
3945 }
3946 return D_O_K;
3947 }
3948
3949 // It took awhile to get these values right, so no meddlin'!
3950 int32_t playTune1()
3951 {
3952 return playTune(0);
3953 }
3954 int32_t playTune2()
3955 {
3956 return playTune(81);
3957 }
3958 int32_t playTune3()
3959 {
3960 return playTune(233);
3961 }
3962 int32_t playTune4()
3963 {
3964 return playTune(553);
3965 }
3966 int32_t playTune5()
3967 {
3968 return playTune(814);
3969 }
3970 int32_t playTune6()
3971 {
3972 return playTune(985);
3973 }
3974 int32_t playTune7()
3975 {
3976 return playTune(1153);
3977 }
3978 int32_t playTune8()
3979 {
3980 return playTune(1333);
3981 }
3982 int32_t playTune9()
3983 {
3984 return playTune(1556);
3985 }
3986 int32_t playTune10()
3987 {
3988 return playTune(1801);
3989 }
3990 int32_t playTune11()
3991 {
3992 return playTune(2069);
3993 }
3994 int32_t playTune12()
3995 {
3996 return playTune(2189);
3997 }
3998 int32_t playTune13()
3999 {
4000 return playTune(2569);
4001 }
4002 int32_t playTune14()
4003 {
4004 return playTune(2753);
4005 }
4006 int32_t playTune15()
4007 {
4008 return playTune(2856);
4009 }
4010 int32_t playTune16()
4011 {
4012 return playTune(3042);
4013 }
4014 int32_t playTune17()
4015 {
4016 return playTune(3125);
4017 }
4018 int32_t playTune18()
4019 {
4020 return playTune(3217);
4021 }
4022 int32_t playTune19()
4023 {
4024 return playTune(3296);
4025 }
4026
4027 int32_t playTune(int32_t pos)
4028 {
4029 zc_stop_midi();
4030
4031 if(zcmusic != NULL)
4032 {
4033 zcmusic_stop(zcmusic);
4034 zcmusic_unload_file(zcmusic);
4035 zcmusic = NULL;
4036 zcmixer->newtrack = NULL;
4037 }
4038
4039 if(zc_play_midi((MIDI*)zcdata[THETRAVELSOFLINK_MID].dat,true)==0)
4040 {
4041 zc_midi_seek(pos);
4042 set_media_tunes();
4043 }
4044
4045 return D_O_K;
4046 }
4047
4048 int32_t stopMusic()
4049 {
4050 zc_stop_midi();
4051
4052 if(zcmusic != NULL)
4053 {
4054 zcmusic_stop(zcmusic);
4055 zcmusic_unload_file(zcmusic);
4056 zcmusic = NULL;
4057 zcmixer->newtrack = NULL;
4058 }
4059
4060 media_menu.select_uid(MENUID_MEDIA_TUNES, false);
4061 media_menu.select_uid(MENUID_MEDIA_PLAYMUSIC, false);
4062 disable_hotkey(ZQKEY_AMBIENT_MUSIC, false);
4063 disable_hotkey(ZQKEY_PLAY_MUSIC, false);
4064
4065 media_menu.disable_uid(MENUID_MEDIA_CHANGETRACK, true);
4066 disable_hotkey(ZQKEY_CHANGE_TRACK, true);
4067 return D_O_K;
4068 }
4069
4070 static int32_t gamemisc1_list[] =
4071 {
4072 5,6,7,8,
4073 9,10,11,12,
4074
4075 37,38,39,40,
4076 41,42,43,44,
4077
4078 71,72,73,74,
4079 75,76,77,78,
4080
4081 -1
4082 };
4083
4084 static int32_t gamemisc2_list[] =
4085 {
4086 13,14,15,16,
4087 17,18,19,20,
4088
4089 45,46,47,48,
4090 49,50,51,52,
4091
4092 79,80,81,82,
4093 83,84,85,86,
4094
4095 -1
4096 };
4097
4098 static int32_t gamemisc3_list[] =
4099 {
4100 21,22,23,24,
4101 25,26,27,28,
4102
4103 53,54,55,56,
4104 57,58,59,60,
4105
4106 87,88,89,90,
4107 91,92,93,94,
4108
4109 -1
4110 };
4111
4112 static int32_t gamemisc4_list[] =
4113 {
4114 29,30,31,32,
4115 33,34,35,36,
4116
4117 61,62,63,64,
4118 65,66,67,68,
4119
4120 95,96,97,98,
4121 99,100,101,102,
4122
4123 -1
4124 };
4125
4126 static TABPANEL gamemisc_tabs[] =
4127 {
4128 // (text)
4129 { (char *)" Misc[0-7] ", D_SELECTED, gamemisc1_list, 0, NULL },
4130 { (char *)" Misc[8-15] ", 0, gamemisc2_list, 0, NULL },
4131 { (char *)" Misc[16-23] ", 0, gamemisc3_list, 0, NULL },
4132 { (char *)" Misc[24-31] ", 0, gamemisc4_list, 0, NULL },
4133 { NULL, 0, NULL, 0, NULL }
4134 };
4135
4136 //to do: Make string boxes larger, and split into two tabs.
4137 static DIALOG gamemiscarray_dlg[] =
4138 {
4139 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
4140
4141 { jwin_win_proc, 0, 10, 310, 224, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Game->Misc[]", NULL, NULL },
4142 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4143 { jwin_tab_proc, 3, 26, 304, 174, vc(14), vc(1), 0, 0, 1, 0, (void *) gamemisc_tabs, NULL, (void *)gamemiscarray_dlg },
4144 { d_dummy_proc, 240, 144, 40, 8, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
4145 { d_dummy_proc, 240, 144, 40, 8, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
4146
4147 //5
4148 { jwin_edit_proc, 8, 42, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4149 { jwin_edit_proc, 8, 42+20, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4150 { jwin_edit_proc, 8, 42+40, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4151 //8
4152 { jwin_edit_proc, 8, 42+60, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4153 { jwin_edit_proc, 8, 42+80, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4154 { jwin_edit_proc, 8, 42+100, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4155 { jwin_edit_proc, 8, 42+120, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4156 { jwin_edit_proc, 8, 42+140, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4157 //13
4158 { jwin_edit_proc, 8, 42, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4159 { jwin_edit_proc, 8, 42+20, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4160 { jwin_edit_proc, 8, 42+40, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4161 { jwin_edit_proc, 8, 42+60, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4162 { jwin_edit_proc, 8, 42+80, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4163 //18
4164 { jwin_edit_proc, 8, 42+100, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4165 { jwin_edit_proc, 8, 42+120, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4166 { jwin_edit_proc, 8, 42+140, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4167 { jwin_edit_proc, 8, 42, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4168 { jwin_edit_proc, 8, 42+20, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4169 //23
4170 { jwin_edit_proc, 8, 42+40, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4171 { jwin_edit_proc, 8, 42+60, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4172 { jwin_edit_proc, 8, 42+80, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4173 { jwin_edit_proc, 8, 42+100, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4174 { jwin_edit_proc, 8, 42+120, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4175 //28
4176 { jwin_edit_proc, 8, 42+140, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4177 { jwin_edit_proc, 8, 42, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4178 { jwin_edit_proc, 8, 42+20, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4179 { jwin_edit_proc, 8, 42+40, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4180 { jwin_edit_proc, 8, 42+60, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4181 //33
4182 { jwin_edit_proc, 8, 42+80, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4183 { jwin_edit_proc, 8, 42+100, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4184 { jwin_edit_proc, 8, 42+120, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4185 { jwin_edit_proc, 8, 42+140, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4186 //37
4187 { jwin_numedit_swap_zsint_proc, 96, 42, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4188 { jwin_numedit_swap_zsint_proc, 96, 42+20, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4189 //39
4190 { jwin_numedit_swap_zsint_proc, 96, 42+40, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4191 { jwin_numedit_swap_zsint_proc, 96, 42+60, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4192 { jwin_numedit_swap_zsint_proc, 96, 42+80, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4193 { jwin_numedit_swap_zsint_proc, 96, 42+100, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4194 { jwin_numedit_swap_zsint_proc, 96, 42+120, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4195 //44
4196 { jwin_numedit_swap_zsint_proc, 96, 42+140, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4197 { jwin_numedit_swap_zsint_proc, 96, 42, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4198 { jwin_numedit_swap_zsint_proc, 96, 42+20, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4199
4200 { jwin_numedit_swap_zsint_proc, 96, 42+40, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4201 { jwin_numedit_swap_zsint_proc, 96, 42+60, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4202 //49
4203 { jwin_numedit_swap_zsint_proc, 96, 42+80, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4204 { jwin_numedit_swap_zsint_proc, 96, 42+100, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4205 { jwin_numedit_swap_zsint_proc, 96, 42+120, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4206 { jwin_numedit_swap_zsint_proc, 96, 42+140, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4207 { jwin_numedit_swap_zsint_proc, 96, 42, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4208 //54
4209 { jwin_numedit_swap_zsint_proc, 96, 42+20, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4210 { jwin_numedit_swap_zsint_proc, 96, 42+40, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4211 { jwin_numedit_swap_zsint_proc, 96, 42+60, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4212 { jwin_numedit_swap_zsint_proc, 96, 42+80, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4213 { jwin_numedit_swap_zsint_proc, 96, 42+100, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4214 //59
4215 { jwin_numedit_swap_zsint_proc, 96, 42+120, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4216 { jwin_numedit_swap_zsint_proc, 96, 42+140, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4217 { jwin_numedit_swap_zsint_proc, 96, 42, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4218 { jwin_numedit_swap_zsint_proc, 96, 42+20, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4219 { jwin_numedit_swap_zsint_proc, 96, 42+40, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4220 //64
4221 { jwin_numedit_swap_zsint_proc, 96, 42+60, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4222 { jwin_numedit_swap_zsint_proc, 96, 42+80, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4223 { jwin_numedit_swap_zsint_proc, 96, 42+100, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4224 { jwin_numedit_swap_zsint_proc, 96, 42+120, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4225 { jwin_numedit_swap_zsint_proc, 96, 42+140, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4226 //69
4227 { jwin_button_proc, 70, 204, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
4228 { jwin_button_proc, 170, 204, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
4229
4230 //71
4231 { jwin_swapbtn_proc, 156, 42, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4232 { jwin_swapbtn_proc, 156, 62, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4233 { jwin_swapbtn_proc, 156, 82, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4234 { jwin_swapbtn_proc, 156, 102, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4235 { jwin_swapbtn_proc, 156, 122, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4236 { jwin_swapbtn_proc, 156, 142, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4237 { jwin_swapbtn_proc, 156, 162, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4238 { jwin_swapbtn_proc, 156, 182, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4239 //79
4240 { jwin_swapbtn_proc, 156, 42, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4241 { jwin_swapbtn_proc, 156, 62, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4242 { jwin_swapbtn_proc, 156, 82, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4243 { jwin_swapbtn_proc, 156, 102, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4244 { jwin_swapbtn_proc, 156, 122, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4245 { jwin_swapbtn_proc, 156, 142, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4246 { jwin_swapbtn_proc, 156, 162, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4247 { jwin_swapbtn_proc, 156, 182, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4248 //87
4249 { jwin_swapbtn_proc, 156, 42, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4250 { jwin_swapbtn_proc, 156, 62, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4251 { jwin_swapbtn_proc, 156, 82, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4252 { jwin_swapbtn_proc, 156, 102, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4253 { jwin_swapbtn_proc, 156, 122, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4254 { jwin_swapbtn_proc, 156, 142, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4255 { jwin_swapbtn_proc, 156, 162, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4256 { jwin_swapbtn_proc, 156, 182, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4257 //95
4258 { jwin_swapbtn_proc, 156, 42, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4259 { jwin_swapbtn_proc, 156, 62, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4260 { jwin_swapbtn_proc, 156, 82, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4261 { jwin_swapbtn_proc, 156, 102, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4262 { jwin_swapbtn_proc, 156, 122, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4263 { jwin_swapbtn_proc, 156, 142, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4264 { jwin_swapbtn_proc, 156, 162, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4265 { jwin_swapbtn_proc, 156, 182, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4266
4267 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
4268 };
4269
4270 void EditGameMiscArray()
4271 {
4272 gamemiscarray_dlg[0].dp2=get_zc_font(font_lfont);
4273 char miscvalue[32][14];
4274 char miscvalue_labels[32][65];
4275 memset(miscvalue, 0, sizeof(miscvalue));
4276 memset(miscvalue_labels, 0, sizeof(miscvalue_labels));
4277 for ( int32_t q = 0; q < 32; q++ )
4278 {
4279 gamemiscarray_dlg[37+q].dp = miscvalue[q];
4280 gamemiscarray_dlg[37+q].fg = QMisc.questmisc[q];
4281 gamemiscarray_dlg[37+q].dp3 = &(gamemiscarray_dlg[71+q]);
4282
4283 strcpy(miscvalue_labels[q], QMisc.questmisc_strings[q]);
4284 if ( miscvalue_labels[q][0] == 0 ) sprintf(miscvalue_labels[q],"Misc[%d]",q);
4285 gamemiscarray_dlg[5+q].dp = miscvalue_labels[q];
4286
4287 }
4288 //also questmisc_strings
4289 int32_t ret;
4290 large_dialog(gamemiscarray_dlg);
4291
4292 do
4293 {
4294 ret = do_zqdialog(gamemiscarray_dlg,65);
4295 for ( int32_t q = 0; q < 32; q++ )
4296 {
4297
4298 QMisc.questmisc[q] = gamemiscarray_dlg[37+q].fg;
4299 strcpy(QMisc.questmisc_strings[q], miscvalue_labels[q]);
4300 }
4301
4302 }
4303 while(ret==68);
4304 }
4305
4306 int32_t onQMiscValues()
4307 {
4308 EditGameMiscArray();
4309 saved=false;
4310 return D_O_K;
4311 }
4312
4313 // +----------+
4314 // | |
4315 // | View Pic |
4316 // | |
4317 // | |
4318 // | |
4319 // +----------+
4320
4321 BITMAP *pic=NULL;
4322 BITMAP *bmap=NULL;
4323 PALETTE picpal;
4324 PALETTE mappal;
4325 int32_t picx=0,picy=0,mapx=0,mapy=0,pblack,pwhite;
4326
4327 double picscale=1.0,mapscale=1.0;
4328 bool vp_showpal=true, vp_showsize=true, vp_center=true;
4329
4330 //INLINE int32_t pal_sum(RGB p) { return p.r + p.g + p.b; }
4331
4332 void get_bw(RGB *pal,int32_t &black,int32_t &white)
4333 {
4334 black=white=1;
4335
4336 for(int32_t i=1; i<256; i++)
4337 {
4338 if(pal_sum(pal[i])<pal_sum(pal[black]))
4339 black=i;
4340
4341 if(pal_sum(pal[i])>pal_sum(pal[white]))
4342 white=i;
4343 }
4344 }
4345
4346 void draw_bw_mouse(int32_t white, int32_t old_mouse, int32_t new_mouse)
4347 {
4348 blit(mouse_bmp[old_mouse][0],mouse_bmp[new_mouse][0],0,0,0,0,16,16);
4349
4350 for(int32_t y=0; y<16; y++)
4351 {
4352 for(int32_t x=0; x<16; x++)
4353 {
4354 if(getpixel(mouse_bmp[new_mouse][0],x,y)!=0)
4355 {
4356 putpixel(mouse_bmp[new_mouse][0],x,y,white);
4357 }
4358 }
4359 }
4360 }
4361
4362 int32_t load_the_pic(BITMAP **dst, PALETTE dstpal)
4363 {
4364 PALETTE temppal;
4365
4366 for(int32_t i=0; i<256; i++)
4367 {
4368 temppal[i]=dstpal[i];
4369 dstpal[i]=RAMpal[i];
4370 }
4371
4372 // set up the new palette
4373 for(int32_t i=0; i<64; i++)
4374 {
4375 dstpal[i].r = i;
4376 dstpal[i].g = i;
4377 dstpal[i].b = i;
4378 }
4379
4380 zc_set_palette(dstpal);
4381
4382 BITMAP *graypic = create_bitmap_ex(8,screen->w,screen->h);
4383 int32_t _w = screen->w-1;
4384 int32_t _h = screen->h-1;
4385
4386 // gray scale the current frame
4387 for(int32_t y=0; y<_h; y++)
4388 {
4389 for(int32_t x=0; x<_w; x++)
4390 {
4391 int32_t c = screen->line[y][x];
4392 int32_t gray = zc_min((temppal[c].r*42 + temppal[c].g*75 + temppal[c].b*14) >> 7, 63);
4393 graypic->line[y][x] = gray;
4394 }
4395 }
4396
4397 blit(graypic,screen,0,0,0,0,screen->w,screen->h);
4398 destroy_bitmap(graypic);
4399 #ifdef __GNUC__
4400 #pragma GCC diagnostic ignored "-Wformat-overflow"
4401 #endif
4402 char extbuf[2][80];
4403 memset(extbuf[0],0,80);
4404 memset(extbuf[1],0,80);
4405 sprintf(extbuf[0], "View Image (%s", snapshotformat_str[0][1]);
4406 strcpy(extbuf[1], snapshotformat_str[0][1]);
4407
4408 for(int32_t i=1; i<ssfmtMAX; ++i)
4409 {
4410 sprintf(extbuf[0], "%s, %s", extbuf[0], snapshotformat_str[i][1]);
4411 sprintf(extbuf[1], "%s;%s", extbuf[1], snapshotformat_str[i][1]);
4412 }
4413
4414 sprintf(extbuf[0], "%s)", extbuf[0]);
4415 #ifdef __GNUC__
4416 #pragma GCC diagnostic pop
4417 #endif
4418
4419 int32_t gotit = getname(extbuf[0],extbuf[1],NULL,imagepath,true);
4420
4421 if(!gotit)
4422 {
4423 zc_set_palette(temppal);
4424 get_palette(dstpal);
4425 return 1;
4426 }
4427
4428 strcpy(imagepath,temppath);
4429
4430 if(*dst)
4431 {
4432 destroy_bitmap(*dst);
4433 }
4434
4435 for(int32_t i=0; i<256; i++)
4436 {
4437 dstpal[i].r = 0;
4438 dstpal[i].g = 0;
4439 dstpal[i].b = 0;
4440 }
4441
4442 *dst = load_bitmap(imagepath,picpal);
4443
4444 if(!*dst)
4445 {
4446 jwin_alert("Error","Error loading image:",imagepath,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4447 return 2;
4448 }
4449
4450 // get_bw(picpal,pblack,pwhite);
4451 // draw_bw_mouse(pwhite);
4452 // gui_bg_color = pblack;
4453 // gui_fg_color = pwhite;
4454
4455 if(vp_center)
4456 {
4457 picx=picy=0;
4458 }
4459 else
4460 {
4461 picx=(*dst)->w-zq_screen_w;
4462 picy=(*dst)->h-zq_screen_h;
4463 }
4464
4465 return 0;
4466 }
4467 int load_the_pic_new(BITMAP **dst, PALETTE dstpal)
4468 {
4469 #ifdef __GNUC__
4470 #pragma GCC diagnostic ignored "-Wformat-overflow"
4471 #endif
4472 char extbuf[2][80];
4473 memset(extbuf[0],0,80);
4474 memset(extbuf[1],0,80);
4475 sprintf(extbuf[0], "View Image (%s", snapshotformat_str[0][1]);
4476 strcpy(extbuf[1], snapshotformat_str[0][1]);
4477
4478 for(int32_t i=1; i<ssfmtMAX; ++i)
4479 {
4480 sprintf(extbuf[0], "%s, %s", extbuf[0], snapshotformat_str[i][1]);
4481 sprintf(extbuf[1], "%s;%s", extbuf[1], snapshotformat_str[i][1]);
4482 }
4483
4484 sprintf(extbuf[0], "%s)", extbuf[0]);
4485 #ifdef __GNUC__
4486 #pragma GCC diagnostic pop
4487 #endif
4488
4489 int32_t gotit = getname(extbuf[0],extbuf[1],NULL,imagepath,true);
4490
4491 if(!gotit)
4492 return 1;
4493
4494 strcpy(imagepath,temppath);
4495
4496 if(*dst)
4497 destroy_bitmap(*dst);
4498
4499 for(int32_t i=0; i<256; i++)
4500 {
4501 dstpal[i].r = 0;
4502 dstpal[i].g = 0;
4503 dstpal[i].b = 0;
4504 }
4505
4506 *dst = load_bitmap(imagepath,dstpal);
4507
4508 if(!*dst)
4509 {
4510 jwin_alert("Error","Error loading image:",imagepath,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4511 return 2;
4512 }
4513
4514 if(vp_center)
4515 {
4516 picx=picy=0;
4517 }
4518 else
4519 {
4520 picx=(*dst)->w-zq_screen_w;
4521 picy=(*dst)->h-zq_screen_h;
4522 }
4523
4524 return 0;
4525 }
4526
4527 int32_t saveMapAsImage(ALLEGRO_BITMAP* bitmap)
4528 {
4529 char buf[200];
4530 int32_t num=0;
4531
4532 do
4533 {
4534 snprintf(buf, 200, "%szquest_map%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
4535 buf[199]='\0';
4536 }
4537 while(num<99999 && exists(buf));
4538
4539 if (!al_save_bitmap(buf, bitmap))
4540 InfoDialog("Error", "Failed to save map image").show();
4541
4542 return D_O_K;
4543 }
4544
4545 int32_t onViewPic()
4546 {
4547 return launchPicViewer(&pic,picpal,&picx,&picy,&picscale,false);
4548 }
4549
4550
4551 class MapViewRTI : public RenderTreeItem
4552 {
4553 public:
4554
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 MapViewRTI(): RenderTreeItem("map_view")
4555 8 {
4556 8 }
4557
4558 int bw, bh, sw, sh, flags;
4559
4560 private:
4561 void render(bool bitmap_resized)
4562 {
4563 BITMAP* bmap4_single = create_bitmap_ex(8,256,176);
4564 set_bitmap_create_flags(true);
4565 ALLEGRO_BITMAP* bmap5_single = al_create_bitmap(256,176);
4566 int curscr = Map.getCurrScr();
4567 for(int32_t y=0; y<8; y++)
4568 {
4569 for(int32_t x=0; x<16; x++)
4570 {
4571 clear_bitmap(bmap4_single);
4572 Map.setCurrScr(y*16+x);
4573 Map.draw(bmap4_single, 0, 0, flags, -1, y*16+x, -1);
4574 stretch_blit(bmap4_single, bmap4_single, 0, 0, 0, 0, 256, 176, 256, 176);
4575 all_render_a5_bitmap(bmap4_single, bmap5_single);
4576 al_draw_scaled_bitmap(bmap5_single, 0, 0, 256, 176, sw * x, sh * y, sw, sh, 0);
4577 }
4578 }
4579
4580 Map.setCurrScr(curscr);
4581 destroy_bitmap(bmap4_single);
4582 al_destroy_bitmap(bmap5_single);
4583 }
4584 };
4585 8 static MapViewRTI rti_map_view;
4586
4587 int32_t launchPicViewer(BITMAP **pictoview, PALETTE pal, int32_t *px2, int32_t *py2, double *scale2, bool isviewingmap, bool skipmenu)
4588 {
4589 restore_mouse();
4590 BITMAP *buf;
4591 bool done=false, redraw=true;
4592
4593 popup_zqdialog_start();
4594
4595 // Always call load_the_map() when viewing the map.
4596 if((!*pictoview || isviewingmap) && (isviewingmap ? load_the_map(skipmenu) : load_the_pic(pictoview,pal)))
4597 {
4598 zc_set_palette(RAMpal);
4599 popup_zqdialog_end();
4600 close_the_map();
4601 return D_O_K;
4602 }
4603
4604 get_bw(pal,pblack,pwhite);
4605
4606 int32_t oldfgcolor = gui_fg_color;
4607 int32_t oldbgcolor = gui_bg_color;
4608
4609 buf = create_bitmap_ex(8,zq_screen_w,zq_screen_h);
4610
4611 if(!buf)
4612 {
4613 jwin_alert("Error","Error creating temp bitmap",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4614 popup_zqdialog_end();
4615 close_the_map();
4616 return D_O_K;
4617 }
4618
4619 static LegacyBitmapRTI viewer_overlay_rti("viewer_overlay");
4620 viewer_overlay_rti.set_size(buf->w, buf->h);
4621 viewer_overlay_rti.a4_bitmap = buf;
4622 viewer_overlay_rti.transparency_index = 15;
4623 get_root_rti()->add_child(&viewer_overlay_rti);
4624
4625 zc_set_palette(pal);
4626
4627 if(isviewingmap)
4628 {
4629 int sw = rti_map_view.width / 16;
4630 int sh = rti_map_view.height / 8;
4631 int scr = Map.getCurrScr();
4632 if (scr >= 0x00 && scr <= 0x7F)
4633 {
4634 int dw = al_get_display_width(all_get_display()) / get_root_rti()->get_transform().xscale;
4635 int dh = al_get_display_height(all_get_display()) / get_root_rti()->get_transform().yscale;
4636 mapx = (-(scr % 16) * sw - sw/2 + dw/2);
4637 mapy = (-(scr / 16) * sh - sh/2 + dh/2);
4638 }
4639 }
4640
4641 int w, h;
4642 if (isviewingmap)
4643 {
4644 w = rti_map_view.width;
4645 h = rti_map_view.height;
4646 }
4647 else
4648 {
4649 w = (*pictoview)->w;
4650 h = (*pictoview)->h;
4651 }
4652
4653 do
4654 {
4655 if (isviewingmap)
4656 {
4657 float scale = *scale2;
4658 int dw = al_get_display_width(all_get_display()) / get_root_rti()->get_transform().xscale;
4659 int dh = al_get_display_height(all_get_display()) / get_root_rti()->get_transform().yscale;
4660 mapx = std::max(mapx, (int)(-w*scale + dw));
4661 mapy = std::max(mapy, (int)(-h*scale + dh));
4662 mapx = std::min(mapx, 0);
4663 mapy = std::min(mapy, 0);
4664 rti_map_view.set_transform({mapx, mapy, scale, scale});
4665 }
4666
4667 if(redraw)
4668 {
4669 clear_to_color(buf,15);
4670
4671 if (!isviewingmap)
4672 stretch_blit(*pictoview, buf, 0, 0, w, h,
4673 int32_t(zq_screen_w + (*px2 - w) * *scale2) / 2, int32_t(zq_screen_h + (*py2 - h) * *scale2) / 2,
4674 int32_t(w * *scale2), int32_t(h * *scale2));
4675
4676 if(vp_showpal)
4677 for(int32_t i=0; i<256; i++)
4678 rectfill(buf,((i&15)<<2)+zq_screen_w-64,((i>>4)<<2)+zq_screen_h-64,((i&15)<<2)+zq_screen_w-64+3,((i>>4)<<2)+zq_screen_h-64+3,i);
4679
4680 if(vp_showsize)
4681 {
4682 textprintf_ex(buf,font,0,zq_screen_h-8,pwhite,pblack,"%dx%d %.2f%%",w,h,*scale2*100.0);
4683 }
4684
4685 if (!isviewingmap)
4686 blit(buf,screen,0,0,0,0,zq_screen_w,zq_screen_h);
4687 redraw=false;
4688 }
4689
4690 custom_vsync();
4691
4692 int32_t step = 16;
4693
4694 if(*scale2 < 1.0)
4695 step = int32_t(4.0/ *scale2);
4696
4697 if(key[KEY_LSHIFT] || key[KEY_RSHIFT])
4698 step <<= 2;
4699
4700 if(CHECK_CTRL_CMD)
4701 step >>= 1;
4702
4703 if(key[KEY_UP])
4704 {
4705 *py2+=step;
4706 redraw=true;
4707 }
4708
4709 if(key[KEY_DOWN])
4710 {
4711 *py2-=step;
4712 redraw=true;
4713 }
4714
4715 if(key[KEY_LEFT])
4716 {
4717 *px2+=step;
4718 redraw=true;
4719 }
4720
4721 if(key[KEY_RIGHT])
4722 {
4723 *px2-=step;
4724 redraw=true;
4725 }
4726
4727 if(keypressed() && !redraw)
4728 switch(readkey()>>8)
4729 {
4730 case KEY_PGUP:
4731 *scale2*=0.95;
4732
4733 if(*scale2<0.1) *scale2=0.1;
4734
4735 redraw=true;
4736 break;
4737
4738 case KEY_PGDN:
4739 *scale2/=0.95;
4740
4741 if(*scale2>5.0) *scale2=5.0;
4742
4743 redraw=true;
4744 break;
4745
4746 case KEY_HOME:
4747 *scale2/=2.0;
4748
4749 if(*scale2<0.1) *scale2=0.1;
4750
4751 redraw=true;
4752 break;
4753
4754 case KEY_END:
4755 *scale2*=2.0;
4756
4757 if(*scale2>5.0) *scale2=5.0;
4758
4759 redraw=true;
4760 break;
4761
4762 case KEY_TILDE:
4763 *scale2=0.5;
4764 redraw=true;
4765 break;
4766
4767 case KEY_Z:
4768 *px2=w-zq_screen_w;
4769 *py2=h-zq_screen_h;
4770 vp_center=false;
4771 redraw=true;
4772 break;
4773
4774 case KEY_1:
4775 *scale2=1.0;
4776 redraw=true;
4777 break;
4778
4779 case KEY_2:
4780 *scale2=2.0;
4781 redraw=true;
4782 break;
4783
4784 case KEY_3:
4785 *scale2=3.0;
4786 redraw=true;
4787 break;
4788
4789 case KEY_4:
4790 *scale2=4.0;
4791 redraw=true;
4792 break;
4793
4794 case KEY_5:
4795 *scale2=5.0;
4796 redraw=true;
4797 break;
4798
4799 case KEY_C:
4800 *px2=*py2=0;
4801 redraw=vp_center=true;
4802 break;
4803
4804 case KEY_S:
4805 vp_showsize = !vp_showsize;
4806 redraw=true;
4807 break;
4808
4809 case KEY_D:
4810 vp_showpal = !vp_showpal;
4811 redraw=true;
4812 break;
4813
4814 case KEY_P:
4815 if(isviewingmap) break;
4816
4817 case KEY_ESC:
4818 done=true;
4819 break;
4820
4821 case KEY_SPACE:
4822 close_the_map();
4823 // TODO: why is `load_the_map` rendering a black dialog?
4824 if(isviewingmap ? load_the_map(skipmenu) : load_the_pic(pictoview,pal)==2)
4825 {
4826 done=true;
4827 }
4828 else
4829 {
4830 redraw=true;
4831 gui_bg_color = pblack;
4832 gui_fg_color = pwhite;
4833 *scale2=1.0;
4834 zc_set_palette(pal);
4835 }
4836
4837 get_bw(pal,pblack,pwhite);
4838 break;
4839 }
4840 }
4841 while(!done);
4842
4843 destroy_bitmap(buf);
4844 zc_set_palette(RAMpal);
4845 gui_fg_color = oldfgcolor;
4846 gui_bg_color = oldbgcolor;
4847
4848 popup_zqdialog_end();
4849 position_mouse_z(0);
4850 viewer_overlay_rti.remove();
4851 close_the_map();
4852 return D_O_K;
4853 }
4854
4855 static DIALOG loadmap_dlg[] =
4856 {
4857 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
4858 { jwin_win_proc, 0, 0, 225, 143, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "View Map", NULL, NULL },
4859 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4860 { jwin_text_proc, 32, 26, 96, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Resolution", NULL, NULL },
4861 // 3
4862 { jwin_radio_proc, 16, 36, 97, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "1/4 - 1024x352", NULL, NULL },
4863 { jwin_radio_proc, 16, 46, 97, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "1/2 - 2048x704", NULL, NULL },
4864 { jwin_radio_proc, 16, 56, 97, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "Full - 4096x1408", NULL, NULL },
4865 { jwin_text_proc, 144, 26, 97, 9, vc(11), vc(1), 0, 0, 0, 0, (void *) "Options", NULL, NULL },
4866 // 7
4867 { jwin_check_proc, 144, 36, 97, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Solidity", NULL, NULL },
4868 { jwin_check_proc, 144, 46, 97, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Flags", NULL, NULL },
4869 { jwin_check_proc, 144, 56, 97, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Dark", NULL, NULL },
4870 { jwin_check_proc, 144, 66, 97, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Items", NULL, NULL },
4871 // 11
4872 { jwin_button_proc, 42, 110, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
4873 { jwin_button_proc, 122, 110, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
4874 { jwin_check_proc, 16, 88, 97, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Save to Image", NULL, NULL },
4875 // 14
4876 { jwin_radio_proc, 16, 66, 97, 9, vc(14), vc(1), 0, 0, 0, 0, (void*)"2x - 8192x2816", NULL, NULL },
4877 { jwin_radio_proc, 16, 76, 97, 9, vc(14), vc(1), 0, 0, 0, 0, (void*)"4x - 16384x5632", NULL, NULL },
4878 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
4879 };
4880
4881 int32_t load_the_map(bool skipmenu)
4882 {
4883 static int32_t res = 0;
4884 static int32_t flags = cDEBUG;
4885
4886 loadmap_dlg[0].dp2 = get_zc_font(font_lfont);
4887 loadmap_dlg[3].flags = (res==2) ? D_SELECTED : 0;
4888 loadmap_dlg[4].flags = (res==1) ? D_SELECTED : 0;
4889 loadmap_dlg[5].flags = (res==0) ? D_SELECTED : 0;
4890 loadmap_dlg[7].flags = (flags&cWALK) ? D_SELECTED : 0;
4891 loadmap_dlg[8].flags = (flags&cFLAGS) ? D_SELECTED : 0;
4892 loadmap_dlg[9].flags = (flags&cNODARK) ? 0 : D_SELECTED;
4893 loadmap_dlg[10].flags = (flags&cNOITEM) ? 0 : D_SELECTED;
4894 loadmap_dlg[13].flags = 0;
4895 loadmap_dlg[14].flags = (res==3) ? D_SELECTED : 0;
4896 loadmap_dlg[15].flags = (res==4) ? D_SELECTED : 0;
4897
4898 if(!skipmenu)
4899 {
4900 large_dialog(loadmap_dlg);
4901
4902 if (do_zqdialog(loadmap_dlg, 11) != 11)
4903 {
4904 return 1;
4905 }
4906
4907 flags = cDEBUG;
4908
4909 if(loadmap_dlg[3].flags&D_SELECTED) res=2;
4910
4911 if(loadmap_dlg[4].flags&D_SELECTED) res=1;
4912
4913 if(loadmap_dlg[5].flags&D_SELECTED) res=0;
4914
4915 if(loadmap_dlg[7].flags&D_SELECTED) flags|=cWALK;
4916
4917 if(loadmap_dlg[8].flags&D_SELECTED) flags|=cFLAGS;
4918
4919 if(!(loadmap_dlg[9].flags&D_SELECTED)) flags|=cNODARK;
4920
4921 if(!(loadmap_dlg[10].flags&D_SELECTED)) flags|=cNOITEM;
4922
4923 if(loadmap_dlg[14].flags&D_SELECTED) res=3;
4924
4925 if(loadmap_dlg[15].flags&D_SELECTED) res=4;
4926 }
4927
4928 int32_t bw = (256*16)>>res;
4929 int32_t bh = (176*8)>>res;
4930 int32_t sw = 256>>res;
4931 int32_t sh = 176>>res;
4932 if(res>2)
4933 {
4934 bw = (256*16)<<(res-2);
4935 bh = (176*8)<<(res-2);
4936 sw = 256<<(res-2);
4937 sh = 176<<(res-2);
4938 }
4939
4940 rti_map_view.flags = flags;
4941 rti_map_view.bw = bw;
4942 rti_map_view.bh = bh;
4943 rti_map_view.sw = sw;
4944 rti_map_view.sh = sh;
4945 rti_map_view.set_size(bw, bh);
4946 rti_map_view.dirty = true;
4947 get_root_rti()->add_child(&rti_map_view);
4948 render_zq();
4949
4950 vp_showpal = false;
4951 get_bw(picpal,pblack,pwhite);
4952 mapx = mapy = 0;
4953 mapscale = 1;
4954 imagepath[0] = 0;
4955
4956 if(loadmap_dlg[13].flags & D_SELECTED) saveMapAsImage(rti_map_view.bitmap);
4957
4958 memcpy(mappal,RAMpal,sizeof(RAMpal));
4959
4960 return 0;
4961 }
4962
4963 void close_the_map()
4964 {
4965 rti_map_view.remove();
4966 }
4967
4968 int32_t onViewMap()
4969 {
4970 return onViewMapEx(false);
4971 }
4972 int32_t onViewMapEx(bool skipmenu)
4973 {
4974 int32_t temp_aligns=ShowMisalignments;
4975 ShowMisalignments=0;
4976 //if(load_the_map()==0)
4977 //{
4978 launchPicViewer(&bmap,mappal,&mapx, &mapy, &mapscale,true,skipmenu);
4979 //}
4980 ShowMisalignments=temp_aligns;
4981 return D_O_K;
4982 }
4983
4984 static const char *mazedirstr[4] = {"North","South","West","East"};
4985 char _pathstr[40]="North,North,North,North";
4986
4987 char *pathstr(byte path[])
4988 {
4989 sprintf(_pathstr,"%s,%s,%s,%s",mazedirstr[path[0]],mazedirstr[path[1]],
4990 mazedirstr[path[2]],mazedirstr[path[3]]);
4991 return _pathstr;
4992 }
4993
4994 char _ticksstr[32]="99.99 seconds";
4995
4996 char *ticksstr(int32_t tics)
4997 {
4998 int32_t mins=tics/(60*60);
4999 tics=tics-(mins*60*60);
5000 int32_t secs=tics/60;
5001 tics=tics-(secs*60);
5002 tics=tics*100/60;
5003
5004 if(mins>0)
5005 {
5006 sprintf(_ticksstr,"%d:%02d.%02d",mins, secs, tics);
5007 }
5008 else
5009 {
5010 sprintf(_ticksstr,"%d.%02d seconds",secs, tics);
5011 }
5012
5013 return _ticksstr;
5014 }
5015 void textprintf_disabled(BITMAP *bmp, AL_CONST FONT *f, int32_t x, int32_t y, int32_t color_hl, int32_t color_sh, AL_CONST char *format, ...)
5016 {
5017 char buf[512];
5018 va_list ap;
5019 ASSERT(bmp);
5020 ASSERT(f);
5021 ASSERT(format);
5022
5023 va_start(ap, format);
5024 uvszprintf(buf, sizeof(buf), format, ap);
5025 va_end(ap);
5026
5027
5028 textout_ex(bmp, f, buf, x+1, y+1, color_hl, -1);
5029
5030 textout_ex(bmp, f, buf, x, y, color_sh, -1);
5031 }
5032
5033 void textprintf_centre_disabled(BITMAP *bmp, AL_CONST FONT *f, int32_t x, int32_t y, int32_t color_hl, int32_t color_sh, AL_CONST char *format, ...)
5034 {
5035 char buf[512];
5036 va_list ap;
5037 ASSERT(bmp);
5038 ASSERT(f);
5039 ASSERT(format);
5040
5041 va_start(ap, format);
5042 uvszprintf(buf, sizeof(buf), format, ap);
5043 va_end(ap);
5044
5045 textout_centre_ex(bmp, f, buf, x+1, y+1, color_hl, -1);
5046 textout_centre_ex(bmp, f, buf, x, y, color_sh, -1);
5047 }
5048
5049 void draw_sqr_frame(size_and_pos const& sqr)
5050 {
5051 jwin_draw_frame(menu1,sqr.x,sqr.y,sqr.tw(),sqr.th(),FR_DEEP);
5052 }
5053 void draw_sqr_icon(size_and_pos const& sqr, BITMAP* icon)
5054 {
5055 stretch_blit(icon, menu1, 0, 0, 16, 16, sqr.x+2, sqr.y+2, sqr.tw()-4, sqr.th()-4);
5056 }
5057 void draw_sqr_nums(size_and_pos const& sqr, FONT* f, bool center, int num)
5058 {
5059 if(center)
5060 textprintf_centre_ex(menu1,f,sqr.x+txtoffs_single.x,sqr.y+txtoffs_single.y,jwin_pal[jcBOXFG],-1,"%d",num);
5061 else
5062 textprintf_ex(menu1,f,sqr.x+txtoffs_single.x,sqr.y+txtoffs_single.y,jwin_pal[jcBOXFG],-1,"%d",num);
5063 }
5064 void draw_sqr_nums(size_and_pos const& sqr, FONT* f, bool center, int num1, int num2)
5065 {
5066 if(center)
5067 {
5068 textprintf_centre_ex(menu1,f,sqr.x+txtoffs_double_1.x,sqr.y+txtoffs_double_1.y,jwin_pal[jcBOXFG],-1,"%d",num1);
5069 textprintf_centre_ex(menu1,f,sqr.x+txtoffs_double_2.x,sqr.y+txtoffs_double_2.y,jwin_pal[jcBOXFG],-1,"%d",num2);
5070 }
5071 else
5072 {
5073 textprintf_ex(menu1,f,sqr.x+txtoffs_double_1.x,sqr.y+txtoffs_double_1.y,jwin_pal[jcBOXFG],-1,"%d",num1);
5074 textprintf_ex(menu1,f,sqr.x+txtoffs_double_2.x,sqr.y+txtoffs_double_2.y,jwin_pal[jcBOXFG],-1,"%d",num2);
5075 }
5076 }
5077 void draw_sqr_btn(size_and_pos const& sqr, const char* txt, int flags, FONT* f = nullptr)
5078 {
5079 if(sqr.x < 0) return;
5080 FONT* tfont = font;
5081 if(f)
5082 font = f;
5083 draw_text_button(menu1, sqr.x, sqr.y, sqr.tw(), sqr.th(), txt, 0, 0, flags, true);
5084 font = tfont;
5085 }
5086 void draw_sqr_btn(size_and_pos const& sqr, int icon, int flags, FONT* f = nullptr)
5087 {
5088 if(sqr.x < 0) return;
5089 FONT* tfont = font;
5090 if(f)
5091 font = f;
5092 draw_icon_button(menu1, sqr.x, sqr.y, sqr.tw(), sqr.th(), icon, 0, 0, flags, true);
5093 font = tfont;
5094 }
5095
5096 void drawpanel()
5097 {
5098 mapscr *scr=Map.CurrScr();
5099 int32_t NextCombo=combobuf[Combo].nextcombo;
5100 int32_t NextCSet=(combobuf[Combo].animflags & AF_CYCLENOCSET) ? CSet : combobuf[Combo].nextcset;
5101
5102 FONT* tfont = font;
5103 if(prv_mode)
5104 {
5105 jwin_draw_frame(menu1,0,preview_panel.y,preview_panel.x+preview_panel.w, preview_panel.h, FR_WIN);
5106 rectfill(menu1,preview_panel.x,preview_panel.y+2,preview_panel.x+preview_panel.w-3,preview_panel.y+preview_panel.h-3,jwin_pal[jcBOX]);
5107 }
5108 else
5109 {
5110 auto& sqr = main_panel;
5111 rectfill(menu1,sqr.x,sqr.y,sqr.x+sqr.w-1,sqr.y+sqr.h-1, jwin_pal[jcBOX]);
5112 refresh(rSCRMAP);
5113 jwin_draw_frame(menu1,sqr.x,sqr.y,sqr.w,sqr.h, FR_WIN);
5114
5115 font = get_custom_font(CFONT_GUI);
5116 draw_sqr_btn(squarepanel_swap_btn, "SWP", 0);
5117 if(compact_square_panels)
5118 {
5119 textprintf_centre_ex(menu1,font,squarepanel_up_btn.cx(),squarepanel_up_btn.y-text_height(font)-2,jwin_pal[jcBOXFG],-1,"%d",compact_active_panel);
5120 draw_sqr_btn(squarepanel_up_btn, BTNICON_ARROW_UP, 0);
5121 draw_sqr_btn(squarepanel_down_btn, BTNICON_ARROW_DOWN, 0);
5122 }
5123 font = tfont;
5124
5125 FONT* sqr_text_font = (is_compact && compact_square_panels) ? get_custom_font(CFONT_GUI) : font;
5126 //Item:
5127 if(itemsqr_pos.x > -1)
5128 {
5129 draw_sqr_frame(itemsqr_pos);
5130 if(scr->hasitem && scr->item > 0)
5131 {
5132 rectfill(menu1,itemsqr_pos.x+2,itemsqr_pos.y+2,itemsqr_pos.x+itemsqr_pos.tw()-3,itemsqr_pos.y+itemsqr_pos.th()-3,0);
5133 overtile16_scale(menu1, itemsbuf[scr->item].tile,itemsqr_pos.x+2,itemsqr_pos.y+2,itemsbuf[scr->item].csets&15,0,itemsqr_pos.tw()-4,itemsqr_pos.th()-4);
5134 }
5135 else draw_sqr_icon(itemsqr_pos, icon_bmp[0][coord_frame]);
5136 draw_sqr_nums(itemsqr_pos, sqr_text_font, panel_align == 1, scr->itemx, scr->itemy);
5137 }
5138 //Flag:
5139 if(flagsqr_pos.x > -1)
5140 {
5141 draw_sqr_frame(flagsqr_pos);
5142 draw_sqr_icon(flagsqr_pos,flag_bmp[Flag%16][coord_frame]);
5143 draw_sqr_nums(flagsqr_pos, sqr_text_font, panel_align == 1, Flag);
5144 }
5145
5146 //Stairs:
5147 if(stairsqr_pos.x > -1)
5148 {
5149 draw_sqr_frame(stairsqr_pos);
5150 draw_sqr_icon(stairsqr_pos,icon_bmp[1][coord_frame]);
5151 draw_sqr_nums(stairsqr_pos, sqr_text_font, panel_align == 1, scr->stairx, scr->stairy);
5152 }
5153
5154 //Green arrival square:
5155 bool disabled_arrival = get_qr(qr_NOARRIVALPOINT);
5156 if(warparrival_pos.x > -1)
5157 {
5158 draw_sqr_frame(warparrival_pos);
5159 BITMAP* icon = icon_bmp[2][coord_frame];
5160 if(disabled_arrival)
5161 {
5162 icon = create_bitmap_ex(8,16,16);
5163 blit(icon_bmp[2][0], icon, 0, 0, 0, 0, 16, 16);
5164 replColor(icon, 0xE7, 0xEA, 0xEA, false);
5165 replColor(icon, 0xE8, 0xE2, 0xE2, false);
5166 }
5167
5168 draw_sqr_icon(warparrival_pos, icon);
5169 draw_sqr_nums(warparrival_pos, sqr_text_font, panel_align == 1, scr->warparrivalx, scr->warparrivaly);
5170
5171 if(disabled_arrival)
5172 destroy_bitmap(icon);
5173 }
5174
5175 //Blue return squares:
5176 for(int32_t i=0; i<4; i++)
5177 {
5178 if(warpret_pos[i].x < 0) continue;
5179 draw_sqr_frame(warpret_pos[i]);
5180 draw_sqr_icon(warpret_pos[i], icon_bmp[ICON_BMP_RETURN_A+i][coord_frame]);
5181 draw_sqr_nums(warpret_pos[i], sqr_text_font, panel_align == 1, scr->warpreturnx[i], scr->warpreturny[i]);
5182 }
5183
5184 // Enemies
5185 auto& ep = enemy_prev_pos;
5186 if(ep.x > -1)
5187 {
5188 if(ep.fw > -1)
5189 {
5190 rectfill(menu1, ep.x, ep.y, ep.x+ep.tw()-1,ep.y+ep.th()-1,vc(0));
5191 rectfill(menu1, ep.x+ep.fw, ep.y+ep.fh, ep.x+ep.tw()-1, ep.y+ep.th()-1, jwin_pal[jcBOX]);
5192 jwin_draw_frag_frame(menu1, ep.x, ep.y, ep.tw(), ep.th(), ep.fw, ep.fh, FR_DEEP);
5193 }
5194 else
5195 {
5196 rectfill(menu1, ep.x, ep.y, ep.x+ep.tw()-1,ep.y+ep.th()-1,vc(0));
5197 draw_sqr_frame(ep);
5198 }
5199 for(int32_t i=0; i< 10 && Map.CurrScr()->enemy[i]!=0; i++)
5200 {
5201 int32_t id = Map.CurrScr()->enemy[i];
5202 int32_t tile = get_qr(qr_NEWENEMYTILES) ? guysbuf[id].e_tile : guysbuf[id].tile;
5203 int32_t cset = guysbuf[id].cset;
5204 auto& sqr = ep.subsquare(i);
5205 if(tile)
5206 overtile16_scale(menu1, tile+efrontfacingtile(id),sqr.x,sqr.y,cset,0,sqr.tw(),sqr.th());
5207 }
5208 }
5209 }
5210 font = tfont;
5211 }
5212
5213 void show_screen_error(const char *str, int32_t i, int32_t c)
5214 {
5215 rectfill(menu1, screrrorpos.x-text_length(get_zc_font(font_lfont_l),str),screrrorpos.y-(i*16),screrrorpos.x,screrrorpos.y-((i-1)*16)-4,vc(0));
5216 textout_shadowed_ex(menu1,get_zc_font(font_lfont_l), str,screrrorpos.x-text_length(get_zc_font(font_lfont_l),str),screrrorpos.y-(i*16),c,vc(0),-1);
5217 }
5218
5219 void tile_warp_notification(int32_t which, char *buf)
5220 {
5221 char letter = 'A'+which;
5222
5223 switch(Map.CurrScr()->tilewarptype[which])
5224 {
5225 case wtCAVE:
5226 sprintf(buf,"Tile Warp %c: Cave/Item Cellar",letter);
5227 break;
5228
5229 default:
5230 {
5231 char buf2[30];
5232
5233 if(strlen(DMaps[Map.CurrScr()->tilewarpdmap[which]].name)==0)
5234 {
5235 sprintf(buf2,"%d",Map.CurrScr()->tilewarpdmap[which]);
5236 }
5237 else
5238 sprintf(buf2,"%d-%s",Map.CurrScr()->tilewarpdmap[which],DMaps[Map.CurrScr()->tilewarpdmap[which]].name);
5239
5240 sprintf(buf,"Tile Warp %c: %s, %02X", letter, buf2, Map.CurrScr()->tilewarpscr[which]);
5241 break;
5242 }
5243
5244 case wtNOWARP:
5245 sprintf(buf,"Tile Warp %c: Cancel Warp", letter);
5246 break;
5247 }
5248 }
5249
5250 void side_warp_notification(int32_t which, int32_t dir, char *buf)
5251 {
5252 char letter = 'A'+which;
5253 char buf3[16];
5254
5255 if(dir==0 && Map.CurrScr()->timedwarptics)
5256 sprintf(buf3,"%s, Timed",mazedirstr[dir]);
5257 else if(dir==4)
5258 sprintf(buf3,"Timed");
5259 else
5260 strcpy(buf3, mazedirstr[dir]);
5261
5262 switch(Map.CurrScr()->sidewarptype[which])
5263 {
5264 case wtCAVE:
5265 sprintf(buf,"Side Warp %c (%s): Cave/Item Cellar",letter, buf3);
5266 break;
5267
5268 default:
5269 {
5270 // Destination DMap name
5271 if(strlen(DMaps[Map.CurrScr()->sidewarpdmap[which]].name)==0)
5272 {
5273 sprintf(buf,"Side Warp %c (%s): %d, %02X", letter, buf3, Map.CurrScr()->sidewarpdmap[which], Map.CurrScr()->sidewarpscr[which]);
5274 }
5275 else
5276 sprintf(buf,"Side Warp %c (%s): %d-%s, %02X", letter, buf3, Map.CurrScr()->sidewarpdmap[which],DMaps[Map.CurrScr()->sidewarpdmap[which]].name, Map.CurrScr()->sidewarpscr[which]);
5277
5278 break;
5279 }
5280
5281 case wtNOWARP:
5282 sprintf(buf,"Side Warp %c (%s): Cancel Warp", letter, buf3);
5283 break;
5284 }
5285 }
5286
5287 static bool arrowcursor = true; // Used by combo aliases and Combo Brush cursors. -L
5288
5289 void xout(BITMAP* dest, int x, int y, int x2, int y2, int c, int bgc = -1)
5290 {
5291 //BG Fill
5292 if(bgc > -1)
5293 rectfill(dest, x, y, x2, y2, bgc);
5294 ++x; ++y; --x2; --y2;
5295 //Border
5296 safe_rect(dest, x, y, x2, y2, c);
5297 //line(dest, x, y, x2, y, c);
5298 //line(dest, x, y, x, y2, c);
5299 //X
5300 line(dest, x, y, x2, y2, c);
5301 line(dest, x, y2, x2, y, c);
5302 }
5303
5304 void put_autocombo_engravings(BITMAP* dest, combo_auto const& ca, bool selected, int32_t x, int32_t y, int32_t scale)
5305 {
5306 if (!ca.valid())
5307 {
5308 if (ca.getDisplay() > 0)
5309 put_engraving(dest, x, y, 15, scale);
5310 }
5311 else
5312 {
5313 if (ca.getType() == AUTOCOMBO_Z4 || ca.getType() == AUTOCOMBO_DOR)
5314 {
5315 byte hei = vbound(ca.getArg() + 1, 1, 9);
5316 if (selected)
5317 hei = vbound(cauto_height, 1, 9);
5318 put_engraving(dest, x, y, 15 - hei, scale);
5319 }
5320 }
5321 }
5322
5323 void draw_screenunit(int32_t unit, int32_t flags)
5324 {
5325 FONT* tfont = font;
5326 switch(unit)
5327 {
5328 case rSCRMAP:
5329 {
5330 size_and_pos *mini_sqr = &minimap;
5331 size_and_pos *real_mini_sqr = &real_minimap;
5332
5333 if(zoomed_minimap)
5334 {
5335 mini_sqr = &minimap_zoomed;
5336 real_mini_sqr = &real_minimap_zoomed;
5337 }
5338
5339 auto txt_x = real_mini_sqr->x+2+8*real_mini_sqr->xscale;
5340 auto txt_y = real_mini_sqr->y+2+8*real_mini_sqr->yscale;
5341
5342 rectfill(menu1, mini_sqr->x-1, mini_sqr->y-2,mini_sqr->x+mini_sqr->w-1,mini_sqr->y+mini_sqr->h-1,jwin_pal[jcBOX]);
5343 if(zoomed_minimap)
5344 jwin_draw_frame(menu1, mini_sqr->x-1, mini_sqr->y-2,mini_sqr->w,mini_sqr->h,FR_WIN);
5345 jwin_draw_minimap_frame(menu1,real_mini_sqr->x,real_mini_sqr->y,real_mini_sqr->tw(), real_mini_sqr->th(), real_mini_sqr->xscale, FR_DEEP);
5346
5347 if(Map.getCurrMap()<Map.getMapCount())
5348 {
5349 for(int32_t i=0; i<MAPSCRS; i++)
5350 {
5351 auto& sqr = real_mini_sqr->subsquare(i);
5352
5353 if(Map.Scr(i)->valid&mVALID)
5354 {
5355 // Handled by mmap_draw.
5356 }
5357 else
5358 {
5359 if (InvalidBG == 2)
5360 {
5361 draw_checkerboard(menu1, sqr.x, sqr.y, sqr.w);
5362 }
5363 else if (InvalidBG == 1)
5364 {
5365 for(int32_t dy=0; dy<sqr.h; dy++)
5366 {
5367 for(int32_t dx=0; dx<sqr.w; dx++)
5368 {
5369 menu1->line[dy+sqr.y][dx+sqr.x]=vc((((zc_oldrand()%100)/50)?0:8)+(((zc_oldrand()%100)/50)?0:7));
5370 }
5371 }
5372 }
5373 else
5374 {
5375 int32_t offs = 2*(sqr.w/9);
5376 draw_x(menu1, sqr.x+offs, sqr.y+offs, sqr.x+sqr.w-1-offs, sqr.y+sqr.h-1-offs, vc(15));
5377 }
5378 }
5379 }
5380
5381 int32_t s=Map.getCurrScr();
5382
5383 BITMAP* txtbmp = create_bitmap_ex(8,256,64);
5384 clear_bitmap(txtbmp);
5385 int txtscale = zoomed_minimap ? (is_compact ? 2 : 3) : 1;
5386 font = get_zc_font(font_lfont_l);
5387
5388 int32_t space = text_length(font, "255")+2, spc_s = text_length(font, "S")+2, spc_m = text_length(font, "M")+2;
5389 textprintf_disabled(txtbmp,font,0,0,jwin_pal[jcLIGHT],jwin_pal[jcMEDDARK],"M");
5390 static int map_shortcut_tooltip_id = ttip_register_id();
5391 ttip_install(map_shortcut_tooltip_id, "Prev map: ,\nNext map: .", txt_x, txt_y, 30, 20, txt_x, txt_y - 60);
5392
5393 textprintf_ex(txtbmp,font,spc_m,0,jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%-3d",Map.getCurrMap()+1);
5394
5395 textprintf_disabled(txtbmp,font,spc_m+space,0,jwin_pal[jcLIGHT],jwin_pal[jcMEDDARK],"S");
5396 textprintf_ex(txtbmp,font,spc_m+space+spc_s,0,jwin_pal[jcBOXFG],jwin_pal[jcBOX],"0x%02X (%d)",s, s);
5397 masked_stretch_blit(txtbmp, menu1, 0, 0, 256, 64, txt_x, txt_y, 256*txtscale, 64*txtscale);
5398 destroy_bitmap(txtbmp);
5399 }
5400 }
5401 break;
5402 case rMAP:
5403 {
5404 if(!layers_valid(Map.CurrScr()))
5405 fix_layers(Map.CurrScr(), true);
5406
5407 byte bgcol = vc(0);
5408 if (LayerDitherBG > -1)
5409 bgcol = vc(LayerDitherBG);
5410 clear_to_color(mapscreenbmp,0);
5411 if (LayerDitherBG > -1)
5412 {
5413 if (LayerDitherSz > 0)
5414 ditherblit(mapscreenbmp, nullptr, vc(LayerDitherBG), dithChecker, LayerDitherSz);
5415 else
5416 clear_to_color(mapscreenbmp, vc(LayerDitherBG));
5417 }
5418 Map.draw(mapscreenbmp, showedges?16:0, showedges?16:0, Flags, -1, -1, ActiveLayerHighlight ? CurrentLayer : -1);
5419 if(showedges)
5420 {
5421 if(Map.getCurrScr()<128)
5422 {
5423 //not the first row of screens
5424 if(Map.getCurrScr()>15 && !NoScreenPreview)
5425 {
5426 Map.drawrow(mapscreenbmp, 16, 0, Flags, 160, -1, Map.getCurrScr()-16);
5427 }
5428 else
5429 {
5430 Map.drawstaticrow(mapscreenbmp, 16, 0);
5431 }
5432
5433 //not the last row of screens
5434 if(Map.getCurrScr()<112 && !NoScreenPreview)
5435 {
5436 Map.drawrow(mapscreenbmp, 16, 192, Flags, 0, -1, Map.getCurrScr()+16);
5437 }
5438 else
5439 {
5440 Map.drawstaticrow(mapscreenbmp, 16, 192);
5441 }
5442
5443 //not the first column of screens
5444 if(Map.getCurrScr()&0x0F && !NoScreenPreview)
5445 {
5446 Map.drawcolumn(mapscreenbmp, 0, 16, Flags, 15, -1, Map.getCurrScr()-1);
5447 }
5448 else
5449 {
5450 Map.drawstaticcolumn(mapscreenbmp, 0, 16);
5451 }
5452
5453 //not the last column of screens
5454 if((Map.getCurrScr()&0x0F)<15 && !NoScreenPreview)
5455 {
5456 Map.drawcolumn(mapscreenbmp, 272, 16, Flags, 0, -1, Map.getCurrScr()+1);
5457 }
5458 else
5459 {
5460 Map.drawstaticcolumn(mapscreenbmp, 272, 16);
5461 }
5462
5463 //not the first row or first column of screens
5464 if((Map.getCurrScr()>15)&&(Map.getCurrScr()&0x0F) && !NoScreenPreview)
5465 {
5466 Map.drawblock(mapscreenbmp, 0, 0, Flags, 175, -1, Map.getCurrScr()-17);
5467 }
5468 else
5469 {
5470 Map.drawstaticblock(mapscreenbmp, 0, 0);
5471 }
5472
5473 //not the first row or last column of screens
5474 if((Map.getCurrScr()>15)&&((Map.getCurrScr()&0x0F)<15) && !NoScreenPreview)
5475 {
5476 Map.drawblock(mapscreenbmp, 272, 0, Flags, 160, -1, Map.getCurrScr()-15);
5477 }
5478 else
5479 {
5480 Map.drawstaticblock(mapscreenbmp, 272, 0);
5481 }
5482
5483 //not the last row or first column of screens
5484 if((Map.getCurrScr()<112)&&(Map.getCurrScr()&0x0F) && !NoScreenPreview)
5485 {
5486 Map.drawblock(mapscreenbmp, 0, 192, Flags, 15, -1, Map.getCurrScr()+15);
5487 }
5488 else
5489 {
5490 Map.drawstaticblock(mapscreenbmp, 0, 192);
5491 }
5492
5493 //not the last row or last column of screens
5494 if((Map.getCurrScr()<112)&&((Map.getCurrScr()&0x0F)<15) && !NoScreenPreview)
5495 {
5496 Map.drawblock(mapscreenbmp, 272, 192, Flags, 0, -1, Map.getCurrScr()+17);
5497 }
5498 else
5499 {
5500 Map.drawstaticblock(mapscreenbmp, 272, 192);
5501 }
5502 }
5503 }
5504
5505 if(showxypos_icon)
5506 {
5507 if(showxypos_color==vc(15))
5508 safe_rect(mapscreenbmp,showxypos_x+(showedges?16:0),showxypos_y+(showedges?16:0),showxypos_x+(showedges?16:0)+showxypos_w-1,showxypos_y+(showedges?16:0)+showxypos_h-1,showxypos_color);
5509 else
5510 rectfill(mapscreenbmp,showxypos_x+(showedges?16:0),showxypos_y+(showedges?16:0),showxypos_x+(showedges?16:0)+showxypos_w-1,showxypos_y+(showedges?16:0)+showxypos_h-1,showxypos_color);
5511 }
5512
5513 if(showxypos_cursor_icon)
5514 {
5515 safe_rect(mapscreenbmp,showxypos_cursor_x+(showedges?16:0),showxypos_cursor_y+(showedges?16:0),showxypos_cursor_x+(showedges?16:0)+showxypos_w-1,showxypos_cursor_y+(showedges?16:0)+showxypos_h-1,showxypos_cursor_color);
5516 }
5517
5518 if(ShowSquares)
5519 {
5520 if(Map.CurrScr()->stairx || Map.CurrScr()->stairy)
5521 {
5522 int32_t x1 = Map.CurrScr()->stairx+(showedges?16:0);
5523 int32_t y1 = Map.CurrScr()->stairy+(showedges?16:0);
5524 safe_rect(mapscreenbmp,x1,y1,x1+15,y1+15,vc(14));
5525 }
5526
5527 if(Map.CurrScr()->warparrivalx || Map.CurrScr()->warparrivaly)
5528 {
5529 int32_t x1 = Map.CurrScr()->warparrivalx +(showedges?16:0);
5530 int32_t y1 = Map.CurrScr()->warparrivaly +(showedges?16:0);
5531 safe_rect(mapscreenbmp,x1,y1,x1+15,y1+15,vc(10));
5532 }
5533
5534 for(int32_t i=0; i<4; i++) if(Map.CurrScr()->warpreturnx[i] || Map.CurrScr()->warpreturny[i])
5535 {
5536 int32_t x1 = Map.CurrScr()->warpreturnx[i]+(showedges?16:0);
5537 int32_t y1 = Map.CurrScr()->warpreturny[i]+(showedges?16:0);
5538 int32_t clr = vc(9);
5539
5540 if(FlashWarpSquare==i)
5541 {
5542 if(!FlashWarpClk)
5543 FlashWarpSquare=-1;
5544 else if(!(--FlashWarpClk%3))
5545 clr = vc(15);
5546 }
5547
5548 safe_rect(mapscreenbmp,x1,y1,x1+15,y1+15,clr);
5549 }
5550
5551 /*
5552 for (int32_t i=0; i<4; i++) for (int32_t j=0; j<9; i++)
5553 {
5554 int32_t x1 = stx[i][j]+(showedges?16:0);
5555 int32_t y1 = sty[i][j]+(showedges?16:0);
5556 rect(mapscreenbmp,x1,y1,x1+15,y1+15,vc(15));
5557 }
5558 */
5559
5560 }
5561
5562 if(ShowFFCs)
5563 {
5564 mapscr* ffscr = prv_mode?Map.get_prvscr():Map.CurrScr();
5565 for(int32_t i=MAXFFCS-1; i>=0; i--)
5566 {
5567 ffcdata& ff = ffscr->ffcs[i];
5568 if(ff.data !=0 && (CurrentLayer<2 || (ff.flags&ffOVERLAY)))
5569 {
5570 auto x = ff.x+(showedges?16:0);
5571 auto y = ff.y+(showedges?16:0);
5572 safe_rect(mapscreenbmp, x+0, y+0, x+ff.txsz*16-1, y+ff.tysz*16-1, vc(12));
5573 }
5574 }
5575 }
5576
5577 if(!(Flags&cDEBUG) && pixeldb==1)
5578 {
5579 for(int32_t j=168; j<176; j++)
5580 {
5581 for(int32_t i=0; i<256; i++)
5582 {
5583 if(((i^j)&1)==0)
5584 {
5585 putpixel(mapscreenbmp,(showedges?16:0)+i,
5586 (showedges?16:0)+j,vc(blackout_color));
5587 }
5588 }
5589 }
5590 }
5591
5592 if(mapscreensize==1)
5593 {
5594 blit(mapscreenbmp,menu1,0,0,mapscreen_x,mapscreen_y,mapscreenbmp->w,mapscreenbmp->h);
5595 }
5596 else
5597 {
5598 stretch_blit(mapscreenbmp,menu1,0,0,mapscreenbmp->w,mapscreenbmp->h,mapscreen_x,mapscreen_y,int32_t(mapscreensize*mapscreenbmp->w),int32_t(mapscreensize*mapscreenbmp->h));
5599 }
5600
5601 if(showedges)
5602 {
5603 //top preview
5604 for(int32_t j=0; j<int32_t(16*mapscreensize); j++)
5605 {
5606 for(int32_t i=0; i<288*mapscreensize; i++)
5607 {
5608 if(((i^j)&1)==0)
5609 {
5610 putpixel(menu1,mapscreen_x+i,mapscreen_y+j,vc(0));
5611 }
5612 }
5613 }
5614
5615 //bottom preview
5616 for(int32_t j=int32_t(192*mapscreensize); j<int32_t(208*mapscreensize); j++)
5617 {
5618 for(int32_t i=0; i<288*mapscreensize; i++)
5619 {
5620 if(((i^j)&1)==0)
5621 {
5622 putpixel(menu1,mapscreen_x+i,mapscreen_y+j,vc(0));
5623 }
5624 }
5625 }
5626
5627 //left preview
5628 for(int32_t j=int32_t(16*mapscreensize); j<int32_t(192*mapscreensize); j++)
5629 {
5630 for(int32_t i=0; i<16*mapscreensize; i++)
5631 {
5632 if(((i^j)&1)==0)
5633 {
5634 putpixel(menu1,mapscreen_x+i,mapscreen_y+j,vc(0));
5635 }
5636 }
5637
5638 }
5639
5640 //right preview
5641 for(int32_t j=int32_t(16*mapscreensize); j<int32_t(192*mapscreensize); j++)
5642 {
5643 for(int32_t i=int32_t(272*mapscreensize); i<int32_t(288*mapscreensize); i++)
5644 {
5645 if(((i^j)&1)==0)
5646 {
5647 putpixel(menu1,mapscreen_x+i,mapscreen_y+j,vc(0));
5648 }
5649 }
5650 }
5651 }
5652
5653 if(!(Flags&cDEBUG) && pixeldb==2)
5654 {
5655 for(int32_t j=int32_t(168*mapscreensize); j<int32_t(176*mapscreensize); j++)
5656 {
5657 for(int32_t i=0; i<int32_t(256*mapscreensize); i++)
5658 {
5659
5660 if(((i^j)&1)==0)
5661 {
5662 putpixel(menu1,int32_t(mapscreen_x+(showedges?(16*mapscreensize):0)+i),
5663 int32_t(mapscreen_y+(showedges?(16*mapscreensize):0)+j),vc(blackout_color));
5664 }
5665 }
5666 }
5667 }
5668
5669 if(Map.isDark())
5670 {
5671 if((Flags&cNEWDARK) && get_qr(qr_NEW_DARKROOM))
5672 {
5673 BITMAP* tmpDark = create_bitmap_ex(8,16*16,16*11);
5674 BITMAP* tmpDarkTrans = create_bitmap_ex(8,16*16,16*11);
5675 BITMAP* tmpbuf = create_bitmap_ex(8,
5676 mapscreensize*(256+(showedges?32:0)),
5677 mapscreensize*(176+(showedges?32:0)));
5678 BITMAP* tmpbuf2 = create_bitmap_ex(8,
5679 mapscreensize*(256+(showedges?32:0)),
5680 mapscreensize*(176+(showedges?32:0)));
5681 int32_t darkCol = zinit.darkcol;
5682 switch(darkCol) //special cases
5683 {
5684 case BLACK:
5685 darkCol = vc(0);
5686 break;
5687 case WHITE:
5688 darkCol = vc(15);
5689 break;
5690 }
5691 clear_to_color(tmpDark, darkCol);
5692 clear_to_color(tmpDarkTrans, darkCol);
5693 clear_bitmap(tmpbuf);
5694 clear_bitmap(tmpbuf2);
5695 //Handle torch combos
5696 color_map = &trans_table2;
5697 Map.draw_darkness(tmpDark, tmpDarkTrans);
5698 //
5699 mapscr* tmp = Map.CurrScr();
5700 if(tmp->flags9 & fDARK_DITHER)
5701 {
5702 ditherblit(tmpDark, tmpDark, 0, zinit.dither_type, zinit.dither_arg);
5703 ditherblit(tmpDarkTrans, tmpDarkTrans, 0, zinit.dither_type, zinit.dither_arg);
5704 }
5705
5706 if(mapscreensize == 1)
5707 {
5708 blit(tmpDark, tmpbuf, 0, 0, (showedges?16:0), (showedges?16:0), 16*16, 16*11);
5709 blit(tmpDarkTrans, tmpbuf2, 0, 0, (showedges?16:0), (showedges?16:0), 16*16, 16*11);
5710 }
5711 else
5712 {
5713 stretch_blit(tmpDark, tmpbuf, 0, 0, 16*16, 16*11,
5714 (showedges?16:0)*mapscreensize, (showedges?16:0)*mapscreensize,
5715 (16*16)*mapscreensize, (16*11)*mapscreensize);
5716 stretch_blit(tmpDarkTrans, tmpbuf2, 0, 0, 16*16, 16*11,
5717 (showedges?16:0)*mapscreensize, (showedges?16:0)*mapscreensize,
5718 (16*16)*mapscreensize, (16*11)*mapscreensize);
5719 }
5720
5721 if(tmp->flags9 & fDARK_TRANS)
5722 {
5723 draw_trans_sprite(menu1, tmpbuf, mapscreen_x, mapscreen_y);
5724 }
5725 else
5726 {
5727 masked_blit(tmpbuf,menu1,0,0,mapscreen_x,mapscreen_y,tmpbuf->w,tmpbuf->h);
5728 }
5729 draw_trans_sprite(menu1, tmpbuf2, mapscreen_x, mapscreen_y);
5730 color_map = &trans_table;
5731 //
5732 destroy_bitmap(tmpDark);
5733 destroy_bitmap(tmpDarkTrans);
5734 destroy_bitmap(tmpbuf);
5735 destroy_bitmap(tmpbuf2);
5736 }
5737 else if(!(Flags&cNODARK))
5738 {
5739 for(int32_t j=0; j<80*mapscreensize; j++)
5740 {
5741 for(int32_t i=0; i<(80*mapscreensize)-j; i++)
5742 {
5743 if(((i^j)&1)==0)
5744 {
5745 putpixel(menu1,int32_t(mapscreen_x+(showedges?(16*mapscreensize):0))+i,
5746 int32_t(mapscreen_y+(showedges?(16*mapscreensize):0)+j),vc(blackout_color));
5747 }
5748 }
5749 }
5750 }
5751 }
5752
5753 int32_t startxint=mapscreen_x+(showedges?int32_t(16*mapscreensize):0);
5754 int32_t startyint=mapscreen_y+(showedges?int32_t(16*mapscreensize):0);
5755 bool inrect = isinRect(gui_mouse_x(),gui_mouse_y(),startxint,startyint,(startxint+(256*mapscreensize)-1),(startyint+(176*mapscreensize)-1));
5756
5757 if(!(flags&rNOCURSOR) && ((ComboBrush && !ComboBrushPause)||draw_mode==dm_alias) && inrect)
5758 {
5759 int32_t mgridscale=16*mapscreensize;
5760 if(allowHideMouse)
5761 {
5762 if(arrowcursor)
5763 {
5764 arrowcursor = false;
5765 MouseSprite::set(ZQM_BLANK);
5766 }
5767 }
5768 else if(!arrowcursor)
5769 {
5770 arrowcursor = true;
5771 MouseSprite::set(ZQM_NORMAL);
5772 }
5773 int32_t mx=(gui_mouse_x()-mapscreen_x)/mgridscale*mgridscale;
5774 int32_t my=(gui_mouse_y()-mapscreen_y)/mgridscale*mgridscale;
5775 clear_bitmap(brushscreen);
5776 int32_t tempbw=BrushWidth;
5777 int32_t tempbh=BrushHeight;
5778
5779 if(draw_mode==dm_alias)
5780 {
5781 BrushWidth = combo_aliases[combo_apos].width+1;
5782 BrushHeight = combo_aliases[combo_apos].height+1;
5783 }
5784 else if(draw_mode == dm_cpool)
5785 {
5786 BrushWidth = BrushHeight = 1;
5787 combo_pool const& pool = combo_pools[combo_pool_pos];
5788 if(pool.valid())
5789 {
5790 int32_t cid = Combo;
5791 int8_t cset = CSet;
5792 pool.get_w_wrap(cid,cset,cpoolbrush_index/16); //divide to reduce speed
5793 put_combo(brushbmp,0,0,cid,cset,Flags&(cFLAGS|cWALK),0);
5794 }
5795 else clear_bitmap(brushbmp);
5796 }
5797 else if (draw_mode == dm_auto)
5798 {
5799 BrushWidth = BrushHeight = 1;
5800 /*combo_auto const& pool = combo_autos[combo_auto_pos];
5801 if (pool.valid())
5802 {
5803 int32_t cid = Combo;
5804 int8_t cset = CSet;
5805 pool.get_w_wrap(cid, cset, cpoolbrush_index / 16); //divide to reduce speed
5806 put_combo(brushbmp, 0, 0, cid, cset, Flags & (cFLAGS | cWALK), 0);
5807 }
5808 else clear_bitmap(brushbmp);*/
5809 }
5810
5811 if((FloatBrush)&&(draw_mode!=dm_alias))
5812 {
5813 stretch_blit(brushbmp, brushscreen, 0, 0, BrushWidth*16, BrushHeight*16, mx-(SHADOW_DEPTH*mapscreensize), my-(SHADOW_DEPTH*mapscreensize), BrushWidth*mgridscale, BrushHeight*mgridscale);
5814
5815 //shadow
5816 for(int32_t i=0; i<SHADOW_DEPTH*mapscreensize; i++)
5817 {
5818 for(int32_t j=0; j<BrushHeight*mgridscale; j++)
5819 {
5820 if((((i^j)&1)==1) && (my+j)<12*mgridscale)
5821 {
5822 putpixel(brushscreen,mx+i+(BrushWidth*mgridscale)-(SHADOW_DEPTH*mapscreensize),my+j,vc(0));
5823 }
5824 }
5825 }
5826
5827 for(int32_t i=0; i<BrushWidth*mgridscale; i++)
5828 {
5829 for(int32_t j=0; j<SHADOW_DEPTH*mapscreensize; j++)
5830 {
5831 if((((i^j)&1)==1) && (mx+i)<16*mgridscale)
5832 {
5833 putpixel(brushscreen,mx+i,my+j+(BrushHeight*mgridscale)-(SHADOW_DEPTH*mapscreensize),vc(0));
5834 }
5835 }
5836 }
5837 }
5838 else
5839 {
5840 if(draw_mode!=dm_alias)
5841 {
5842 stretch_blit(brushbmp, brushscreen, 0, 0, BrushWidth*16, BrushHeight*16, mx, my, BrushWidth*mgridscale, BrushHeight*mgridscale);
5843 }
5844 else
5845 {
5846 combo_alias *combo = &combo_aliases[combo_apos];
5847
5848 switch(alias_origin)
5849 {
5850 case 0:
5851 stretch_blit(brushbmp, brushscreen, 0, 0, BrushWidth*16, BrushHeight*16, mx, my, BrushWidth*mgridscale, BrushHeight*mgridscale);
5852 break;
5853
5854 case 1:
5855 stretch_blit(brushbmp, brushscreen, (mx<combo->width*mgridscale)?((combo->width)*16)-mx/mapscreensize:0, 0, BrushWidth*16, BrushHeight*16, zc_max((mx-(combo->width)*mgridscale),0), my, BrushWidth*mgridscale, BrushHeight*mgridscale);
5856 break;
5857
5858 case 2:
5859 stretch_blit(brushbmp, brushscreen, 0, (my<combo->height*mgridscale)?((combo->height)*16)-my/mapscreensize:0, BrushWidth*16, BrushHeight*16, mx, zc_max((my-(combo->height)*mgridscale),0), BrushWidth*mgridscale, BrushHeight*mgridscale);
5860 break;
5861
5862 case 3:
5863 stretch_blit(brushbmp, brushscreen, (mx<combo->width*mgridscale)?((combo->width)*16)-mx/mapscreensize:0, (my<combo->height*mgridscale)?((combo->height)*16)-my/mapscreensize:0, BrushWidth*16, BrushHeight*16, zc_max((mx-(combo->width)*mgridscale),0), zc_max((my-(combo->height)*mgridscale),0), BrushWidth*mgridscale, BrushHeight*mgridscale);
5864 break;
5865 }
5866 }
5867 }
5868
5869 masked_blit(brushscreen, menu1, 0, 0, mapscreen_x, mapscreen_y, (16+(showedges?2:0))*mgridscale, (11+(showedges?2:0))*mgridscale);
5870 BrushWidth=tempbw;
5871 BrushHeight=tempbh;
5872 }
5873 else
5874 {
5875 if(!arrowcursor)
5876 {
5877 MouseSprite::set(ZQM_NORMAL);
5878 arrowcursor = true;
5879 }
5880 }
5881
5882 if(ShowGrid)
5883 {
5884 int32_t w=16;
5885 int32_t h=11;
5886
5887 if(showedges)
5888 {
5889 w=18;
5890 h=13;
5891 }
5892
5893 for(int32_t x=16; x<w*16; x+=16)
5894 {
5895 _allegro_vline(menu1, (x*mapscreensize)+mapscreen_x, mapscreen_y, mapscreen_y+(h*16*mapscreensize)-1, vc(GridColor));
5896 }
5897
5898 for(int32_t y=16; y<h*16; y+=16)
5899 {
5900 _allegro_hline(menu1, mapscreen_x, (y*mapscreensize)+mapscreen_y, mapscreen_x+(w*16*mapscreensize)-1, vc(GridColor));
5901 }
5902 }
5903
5904 // Map tabs
5905 font = get_custom_font(CFONT_GUI);
5906
5907 map_page[current_mappage].map=Map.getCurrMap();
5908 map_page[current_mappage].screen=Map.getCurrScr();
5909
5910 for(int32_t btn=0; btn<mappage_count; ++btn)
5911 {
5912 char tbuf[15];
5913 sprintf(tbuf, "%d:%02X", map_page[btn].map+1, map_page[btn].screen);
5914 draw_layer_button(menu1,map_page_bar[btn].x, map_page_bar[btn].y, map_page_bar[btn].w, map_page_bar[btn].h,tbuf,(btn==current_mappage?D_SELECTED:0));
5915 }
5916 }
5917 break;
5918 case rCOMBOS:
5919 {
5920 auto real_h = combolist_window.h;
5921 jwin_draw_frame(menu1,combolist_window.x,combolist_window.y,combolist_window.w,real_h, FR_WIN);
5922 rectfill(menu1,combolist_window.x+2,combolist_window.y+2,combolist_window.x+combolist_window.w-3,combolist_window.y+real_h-3,jwin_pal[jcBOX]);
5923
5924 //Scrollers
5925 for(int32_t c = 0; c < num_combo_cols; ++c)
5926 {
5927 auto& pos = combolistscrollers[c];
5928
5929 { //Scroll up
5930 auto& p = pos.subsquare(0);
5931 jwin_draw_frame(menu1,p.x,p.y,p.w,p.h,FR_ETCHED);
5932
5933 for(int32_t i=0; i<3; i++)
5934 {
5935 _allegro_hline(menu1, p.x+5-i, p.y+4+i, p.x+5+i, jwin_pal[jcBOXFG]);
5936 }
5937 }
5938
5939 { //Scroll down
5940 auto& p = pos.subsquare(1);
5941 jwin_draw_frame(menu1,p.x,p.y,p.w,p.h,FR_ETCHED);
5942
5943 for(int32_t i=0; i<3; i++)
5944 {
5945 _allegro_hline(menu1,p.x+5-i,p.y+6-i, p.x+5+i, jwin_pal[jcBOXFG]);
5946 }
5947 }
5948 }
5949
5950 if(draw_mode==dm_alias)
5951 {
5952 if(LinkedScroll)
5953 {
5954 int tmp = current_comboalist;
5955 for(int q = tmp-1; q >= 0; --q)
5956 {
5957 combo_alistpos[q] = combo_alistpos[q+1]-(comboaliaslist[q].w*comboaliaslist[q].h);
5958 if(combo_alistpos[q] < 0)
5959 {
5960 tmp = 0;
5961 combo_alistpos[0] = 0;
5962 break;
5963 }
5964 }
5965 for(int q = tmp+1; q < num_combo_cols; ++q)
5966 combo_alistpos[q] = combo_alistpos[q-1]+(comboaliaslist[q-1].w*comboaliaslist[q-1].h);
5967 for(int q = 0; q < num_combo_cols; ++q)
5968 if(combo_apos >= combo_alistpos[q] && combo_apos < combo_alistpos[q] + (comboaliaslist[q].w*comboaliaslist[q].h))
5969 {
5970 current_comboalist = q;
5971 break;
5972 }
5973 }
5974 for(int32_t c = 0; c < num_combo_cols; ++c)
5975 {
5976 auto& pos = comboaliaslist[c];
5977 rectfill(menu1,pos.x,pos.y,pos.x+(pos.w*pos.xscale)-1,pos.y+(pos.h*pos.yscale)-1,0);
5978 jwin_draw_frame(menu1,pos.x-2,pos.y-2,(pos.w*pos.xscale)+4,(pos.h*pos.yscale)+4,FR_DEEP);
5979 }
5980
5981 auto& prev = comboalias_preview;
5982 jwin_draw_frame(menu1, prev.x-2, prev.y-2, prev.w+4, prev.h+4,FR_DEEP);
5983
5984 BITMAP *prv = create_bitmap_ex(8,64,64);
5985 clear_bitmap(prv);
5986 int32_t scalefactor = 1;
5987
5988 for(int32_t j=0; j<num_combo_cols; ++j)
5989 {
5990 auto per_page = (comboaliaslist[j].w * comboaliaslist[j].h);
5991 if(combo_alistpos[j] + per_page >= MAXCOMBOALIASES)
5992 combo_alistpos[j] = MAXCOMBOALIASES-per_page;
5993 auto& col = comboaliaslist[j];
5994 for(int32_t i=0; i<(comboaliaslist[j].w*comboaliaslist[j].h); i++)
5995 {
5996 draw_combo_alias_thumbnail(menu1, &combo_aliases[combo_alistpos[j]+i],
5997 (i%col.w)*col.xscale+col.x, (i/col.w)*col.yscale+col.y, col.xscale/16);
5998 }
5999
6000 if((combo_aliases[combo_apos].width>7)||(combo_aliases[combo_apos].height>7))
6001 {
6002 scalefactor=4;
6003 }
6004 else if((combo_aliases[combo_apos].width>3)||(combo_aliases[combo_apos].height>3))
6005 {
6006 scalefactor=2;
6007 }
6008
6009
6010 if(j==current_comboalist)
6011 {
6012 stretch_blit(brushbmp, prv, 0,0,scalefactor*64,zc_min(scalefactor*64,176),0,0,64,scalefactor==4?44:64);
6013 blit(prv,menu1,0,0,comboalias_preview.x,comboalias_preview.y,comboalias_preview.w,comboalias_preview.h);
6014
6015 int32_t rect_pos=combo_apos-combo_alistpos[current_comboalist];
6016
6017 if((rect_pos>=0)&&(rect_pos<(combo_alistpos[current_comboalist]+(col.w*col.h))))
6018 {
6019 int selw = col.xscale;
6020 int selh = col.yscale;
6021 int x1 = (rect_pos&(col.w-1))*col.xscale+col.x;
6022 int y1 = (rect_pos/col.w)*col.yscale+col.y;
6023 safe_rect(menu1,x1,y1,x1+selw-1,y1+selh-1,vc(CmbCursorCol),2);
6024 }
6025 }
6026 }
6027
6028 destroy_bitmap(prv);
6029 }
6030 else if(draw_mode==dm_cpool)
6031 {
6032 if(LinkedScroll)
6033 {
6034 int tmp = current_cpoollist;
6035 for(int q = tmp-1; q >= 0; --q)
6036 {
6037 combo_pool_listpos[q] = combo_pool_listpos[q+1]-(comboaliaslist[q].w*comboaliaslist[q].h);
6038 if(combo_pool_listpos[q] < 0)
6039 {
6040 tmp = 0;
6041 combo_pool_listpos[0] = 0;
6042 break;
6043 }
6044 }
6045 for(int q = tmp+1; q < num_combo_cols; ++q)
6046 combo_pool_listpos[q] = combo_pool_listpos[q-1]+(comboaliaslist[q-1].w*comboaliaslist[q-1].h);
6047 for(int q = 0; q < num_combo_cols; ++q)
6048 if(combo_pool_pos >= combo_pool_listpos[q] && combo_pool_pos < combo_pool_listpos[q] + (comboaliaslist[q].w*comboaliaslist[q].h))
6049 {
6050 current_cpoollist = q;
6051 break;
6052 }
6053 }
6054 for(int32_t c = 0; c < num_combo_cols; ++c)
6055 {
6056 auto& pos = comboaliaslist[c];
6057 rectfill(menu1,pos.x,pos.y,pos.x+(pos.w*pos.xscale)-1,pos.y+(pos.h*pos.yscale)-1,0);
6058 jwin_draw_frame(menu1,pos.x-2,pos.y-2,(pos.w*comboaliaslist[c].xscale)+4,(pos.h*comboaliaslist[c].yscale)+4,FR_DEEP);
6059 }
6060
6061 for (int32_t j = 0; j < num_combo_cols; ++j) //the actual panes
6062 {
6063 auto per_page = (comboaliaslist[j].w * comboaliaslist[j].h);
6064 if(combo_pool_listpos[j] + per_page >= MAXCOMBOPOOLS)
6065 combo_pool_listpos[j] = MAXCOMBOPOOLS-per_page;
6066 for(int32_t i=0; i<(comboaliaslist[j].w*comboaliaslist[j].h); i++)
6067 {
6068 int32_t cid=-1; int8_t cs=CSet;
6069 combo_pool const& cp = combo_pools[combo_pool_listpos[j]+i];
6070
6071 auto& list = comboaliaslist[j];
6072 if(cp.get_w(cid,cs,0) && !combobuf[cid].tile)
6073 {
6074 cid = -1; //no tile to draw
6075 }
6076 auto cx = (i%list.w)*list.xscale+list.x;
6077 auto cy = (i/list.w)*list.yscale+list.y;
6078 put_combo(menu1,cx,cy,cid,cs,Flags&(cFLAGS|cWALK),0,list.xscale/16);
6079 }
6080 }
6081 int32_t rect_pos=combo_pool_pos-combo_pool_listpos[current_cpoollist];
6082
6083 if((rect_pos>=0)&&(rect_pos<(combo_pool_listpos[current_cpoollist]+(comboaliaslist[current_cpoollist].w*comboaliaslist[current_cpoollist].h))))
6084 {
6085 int selw = comboaliaslist[current_cpoollist].xscale;
6086 int selh = comboaliaslist[current_cpoollist].yscale;
6087 int x1 = (rect_pos&(comboaliaslist[current_cpoollist].w-1))*comboaliaslist[current_cpoollist].xscale+comboaliaslist[current_cpoollist].x;
6088 int y1 = (rect_pos/comboaliaslist[current_cpoollist].w)*comboaliaslist[current_cpoollist].yscale+comboaliaslist[current_cpoollist].y;
6089 safe_rect(menu1,x1,y1,x1+selw-1,y1+selh-1,vc(CmbCursorCol),2);
6090 }
6091
6092 //Handle Preview
6093 combo_pool const& cpool = combo_pools[combo_pool_pos];
6094
6095 int32_t cid; int8_t cs;
6096 size_t total = weighted_cpool ? cpool.getTotalWeight() : cpool.combos.size();
6097 size_t ind = 0;
6098 size_t indw = combopool_preview.w/16;
6099 size_t indh = combopool_preview.h/16;
6100 size_t rows = total ? vbound(total/indw,1,indh) : 0;
6101 if (is_compact)
6102 rows = vbound(rows, 1, 3);
6103 else
6104 rows = vbound(rows, 1, 4);
6105 size_t real_height = rows*16;
6106
6107 cpool_prev_visible = rows > 0;
6108 if(rows)
6109 {
6110 jwin_draw_frame(menu1,combopool_preview.x-2,combopool_preview.y-2,
6111 combopool_preview.w+4,real_height+4,FR_DEEP);
6112 rectfill(menu1,combopool_preview.x,combopool_preview.y,
6113 combopool_preview.x+combopool_preview.w-1,
6114 combopool_preview.y+real_height-1,vc(0));
6115 draw_text_button(menu1,combopool_prevbtn.x,combopool_prevbtn.y,
6116 combopool_prevbtn.w,combopool_prevbtn.h,
6117 weighted_cpool ? "Weighted" : "Unweighted",vc(1),vc(14),0,true);
6118 if(!is_compact)
6119 textprintf_ex(menu1,font,combopool_prevbtn.x+combopool_prevbtn.w+5,
6120 combopool_prevbtn.y,jwin_pal[jcBOXFG],-1,"Preview");
6121 for(auto y = 0; y < real_height; y += 16)
6122 {
6123 for(auto x = 0; x < combopool_preview.w; x += 16, ++ind)
6124 {
6125 auto nx = combopool_preview.x+x, ny = combopool_preview.y+y;
6126 if(ind < total)
6127 {
6128 cs = CSet;
6129 if(weighted_cpool
6130 ? cpool.get_w(cid,cs,ind)
6131 : cpool.get_ind(cid,cs,ind))
6132 {
6133 put_combo(menu1,nx,ny,cid,cs,Flags&(cFLAGS|cWALK),0);
6134 continue;
6135 }
6136 }
6137 //No combo to display
6138 xout(menu1, nx, ny, nx+15, ny+15, vc(15));
6139 }
6140 }
6141 }
6142 }
6143 else if (draw_mode == dm_auto)
6144 {
6145 if (LinkedScroll)
6146 {
6147 int tmp = current_cautolist;
6148 for (int q = tmp - 1; q >= 0; --q)
6149 {
6150 combo_auto_listpos[q] = combo_auto_listpos[q + 1] - (comboaliaslist[q].w * comboaliaslist[q].h);
6151 if (combo_auto_listpos[q] < 0)
6152 {
6153 tmp = 0;
6154 combo_auto_listpos[0] = 0;
6155 break;
6156 }
6157 }
6158 for (int q = tmp + 1; q < num_combo_cols; ++q)
6159 combo_auto_listpos[q] = combo_auto_listpos[q - 1] + (comboaliaslist[q - 1].w * comboaliaslist[q - 1].h);
6160 for (int q = 0; q < num_combo_cols; ++q)
6161 if (combo_auto_pos >= combo_auto_listpos[q] && combo_auto_pos < combo_auto_listpos[q] + (comboaliaslist[q].w * comboaliaslist[q].h))
6162 {
6163 current_cautolist = q;
6164 break;
6165 }
6166 }
6167 for (int32_t c = 0; c < num_combo_cols; ++c)
6168 {
6169 auto& pos = comboaliaslist[c];
6170 rectfill(menu1, pos.x, pos.y, pos.x + (pos.w * pos.xscale) - 1, pos.y + (pos.h * pos.yscale) - 1, 0);
6171 jwin_draw_frame(menu1, pos.x - 2, pos.y - 2, (pos.w * comboaliaslist[c].xscale) + 4, (pos.h * comboaliaslist[c].yscale) + 4, FR_DEEP);
6172 }
6173
6174 for (int32_t j = 0; j < num_combo_cols; ++j) //the actual panes
6175 {
6176 auto per_page = (comboaliaslist[j].w * comboaliaslist[j].h);
6177 if(combo_auto_listpos[j] + per_page >= MAXAUTOCOMBOS)
6178 combo_auto_listpos[j] = MAXAUTOCOMBOS-per_page;
6179 for (int32_t i = 0; i < (comboaliaslist[j].w * comboaliaslist[j].h); i++)
6180 {
6181 int32_t cid = -1; int8_t cs = CSet;
6182 combo_auto const& ca = combo_autos[combo_auto_listpos[j] + i];
6183
6184 auto& list = comboaliaslist[j];
6185 cid = ca.getDisplay();
6186 if (cid == 0)
6187 cid = -1;
6188 auto cx = (i % list.w) * list.xscale + list.x;
6189 auto cy = (i / list.w) * list.yscale + list.y;
6190 put_combo(menu1, cx, cy, cid, cs, Flags & (cFLAGS | cWALK), 0, list.xscale / 16);
6191 put_autocombo_engravings(menu1, ca, combo_auto_listpos[j] + i == combo_auto_pos, cx, cy, list.xscale / 16);
6192 }
6193 }
6194 int32_t rect_pos = combo_auto_pos - combo_auto_listpos[current_cautolist];
6195
6196 if ((rect_pos >= 0) && (rect_pos < (combo_auto_listpos[current_cautolist] + (comboaliaslist[current_cautolist].w * comboaliaslist[current_cautolist].h))))
6197 {
6198 int selw = comboaliaslist[current_cautolist].xscale;
6199 int selh = comboaliaslist[current_cautolist].yscale;
6200 int x1 = (rect_pos & (comboaliaslist[current_cautolist].w - 1)) * comboaliaslist[current_cautolist].xscale + comboaliaslist[current_cautolist].x;
6201 int y1 = (rect_pos / comboaliaslist[current_cautolist].w) * comboaliaslist[current_cautolist].yscale + comboaliaslist[current_cautolist].y;
6202 safe_rect(menu1, x1, y1, x1 + selw - 1, y1 + selh - 1, vc(CmbCursorCol), 2);
6203
6204 combo_auto const& ca = combo_autos[combo_auto_pos];
6205 put_autocombo_engravings(menu1, ca, true, x1, y1, selw / 16);
6206 }
6207 }
6208 else
6209 {
6210 if(LinkedScroll)
6211 {
6212 int tmp = current_combolist;
6213 for(int q = tmp-1; q >= 0; --q)
6214 {
6215 First[q] = First[q+1]-(combolist[q].w*combolist[q].h);
6216 if(First[q] < 0)
6217 {
6218 tmp = 0;
6219 First[0] = 0;
6220 break;
6221 }
6222 }
6223 for(int q = tmp+1; q < num_combo_cols; ++q)
6224 First[q] = First[q-1]+(combolist[q-1].w*combolist[q-1].h);
6225 for(int q = 0; q < num_combo_cols; ++q)
6226 if(Combo >= First[q] && Combo < First[q] + (combolist[q].w*combolist[q].h))
6227 {
6228 current_combolist = q;
6229 break;
6230 }
6231 }
6232 for(int32_t c = 0; c < num_combo_cols; ++c)
6233 {
6234 auto& pos = combolist[c];
6235 rectfill(menu1,pos.x,pos.y,pos.x+(pos.w*pos.xscale)-1,pos.y+(pos.h*pos.yscale)-1,0);
6236 jwin_draw_frame(menu1,pos.x-2,pos.y-2,(pos.w*pos.xscale)+4,(pos.h*pos.yscale)+4,FR_DEEP);
6237 }
6238
6239 int32_t drawmap, drawscr;
6240 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
6241 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
6242
6243 for(int32_t j=0; j<num_combo_cols; ++j)
6244 {
6245 auto per_page = (combolist[j].w * combolist[j].h);
6246 if(First[j] + per_page >= MAXCOMBOS)
6247 First[j] = MAXCOMBOS-per_page;
6248 for(int32_t i=0; i<(combolist[j].w*combolist[j].h); i++)
6249 {
6250 put_combo(menu1,(i%combolist[j].w)*combolist[j].xscale+combolist[j].x,
6251 (i/combolist[j].w)*combolist[j].yscale+combolist[j].y,
6252 i+First[j],CSet,Flags&(cFLAGS|cWALK),0,combolist[j].xscale/16);
6253 }
6254 }
6255
6256 int32_t rect_pos=Combo-First[current_combolist];
6257
6258 if((rect_pos>=0)&&(rect_pos<(combo_pool_listpos[current_combolist]+(combolist[current_combolist].w*combolist[current_combolist].h))))
6259 {
6260 int selw = (AutoBrush?BrushWidth:1)*combolist[current_combolist].xscale;
6261 int selh = (AutoBrush?BrushHeight:1)*combolist[current_combolist].yscale;
6262 int x1 = (rect_pos&(combolist[current_combolist].w-1))*combolist[current_combolist].xscale+combolist[current_combolist].x;
6263 int y1 = (rect_pos/combolist[current_combolist].w)*combolist[current_combolist].yscale+combolist[current_combolist].y;
6264 safe_rect(menu1,x1,y1,x1+selw-1,y1+selh-1,vc(CmbCursorCol),2);
6265 }
6266 }
6267 }
6268 break;
6269 case rCOMBO:
6270 {
6271 int32_t drawmap, drawscr;
6272 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
6273 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
6274
6275 // Combo preview
6276 int32_t cid = Combo; int8_t cs = CSet;
6277 if(draw_mode == dm_alias)
6278 {
6279 cid = combo_aliases[combo_apos].combos[0];
6280 cs = wrap(combo_aliases[combo_apos].csets[0]+alias_cset_mod, 0, 13);
6281 }
6282 else if(draw_mode == dm_cpool)
6283 {
6284 combo_pool const& cpool = combo_pools[combo_pool_pos];
6285 cid = 0;
6286 cpool.get_w(cid,cs,0);
6287 }
6288 else if (draw_mode == dm_auto)
6289 {
6290 combo_auto const& cauto = combo_autos[combo_auto_pos];
6291 cid = cauto.getDisplay();
6292 }
6293 static BITMAP *combo_preview_bmp=create_bitmap_ex(8,32,32);
6294 static BITMAP *cycle_preview_bmp=create_bitmap_ex(8,32,32);
6295 // Combo
6296 put_combo(combo_preview_bmp,0,0,cid,cs,Flags&(cFLAGS|cWALK),0);
6297 jwin_draw_frame(menu1,combo_preview.x-2,combo_preview.y-2,combo_preview.w+4,combo_preview.h+4, FR_DEEP);
6298 stretch_blit(combo_preview_bmp, menu1, 0, 0, 16, 16, combo_preview.x, combo_preview.y, combo_preview.w, combo_preview.h);
6299
6300 comboprev_buf[0] = 0;
6301 comboprev_buf2[0] = 0;
6302 if(draw_mode == dm_cpool)
6303 {
6304 sprintf(comboprev_buf,"Pool: %d",combo_pool_pos);
6305 int x = combo_preview_text1.x+(combo_preview_text1.w*combo_preview_text1.xscale);
6306 textbox_out(menu1,txfont,x,combo_preview_text1.y,jwin_pal[jcBOXFG],jwin_pal[jcBOX],comboprev_buf,2,&combo_preview_text1);
6307 }
6308 else if (draw_mode == dm_auto)
6309 {
6310 GUI::ListData ac_types = GUI::ZCListData::autocombotypes();
6311 std::string type_name = ac_types.findText(combo_autos[combo_auto_pos].getType());
6312 if (is_compact)
6313 sprintf(comboprev_buf, "AC: %d CS: %d\n%s", combo_auto_pos, CSet, type_name.c_str());
6314 else
6315 sprintf(comboprev_buf, "Auto: %d CSet: %d\n%s\nEntries: %d", combo_auto_pos, CSet, type_name.c_str(), int32_t(combo_autos[combo_auto_pos].combos.size()));
6316 int x = combo_preview_text1.x + (combo_preview_text1.w * combo_preview_text1.xscale);
6317 textbox_out(menu1, txfont, x, combo_preview_text1.y, jwin_pal[jcBOXFG], jwin_pal[jcBOX], comboprev_buf, 2, &combo_preview_text1);
6318 }
6319 else if(draw_mode != dm_alias)
6320 {
6321 int x = combo_preview_text1.x+(combo_preview_text1.w*combo_preview_text1.xscale);
6322
6323 char shortbuf[512];
6324 char buf[256];
6325 strcpy(buf,combo_class_buf[combobuf[Combo].type].name);
6326 sprintf(comboprev_buf,"Combo: %d\nCSet: %d\n%s",Combo,CSet,buf);
6327 auto ind = strlen(buf)-1;
6328 int x2 = x;
6329 if(x2 - text_length(txfont, buf) <= combolist_window.x)
6330 {
6331 auto dotlen = text_length(txfont, "..");
6332 x2 -= dotlen;
6333 while(x2 - text_length(txfont, buf) <= combolist_window.x)
6334 {
6335 if(ind < 0) break;
6336 buf[ind--] = '\0';
6337 }
6338 while(ind >= 0 && buf[ind] == ' ')
6339 buf[ind--] = 0; //trim spaces
6340 strcat(buf, "..");
6341 }
6342
6343 if(is_compact)
6344 {
6345 char b2[256];
6346 sprintf(b2, "Combo %d CS %d", Combo, CSet);
6347 if(x-text_length(txfont, b2) <= combolist_window.x)
6348 sprintf(b2, "Cmb %d CS %d", Combo, CSet);
6349 sprintf(shortbuf,"%s\n%s",b2,buf);
6350 }
6351 else sprintf(shortbuf,"Combo: %d\nCSet: %d\n%s",Combo,CSet,buf);
6352 textbox_out(menu1,txfont,x,combo_preview_text1.y,jwin_pal[jcBOXFG],jwin_pal[jcBOX],shortbuf,2,&combo_preview_text1);
6353 }
6354
6355 // Cycle
6356 if(!is_compact)
6357 {
6358 int32_t NextCombo=combobuf[Combo].nextcombo;
6359 int32_t NextCSet=(combobuf[Combo].animflags & AF_CYCLENOCSET) ? CSet : combobuf[Combo].nextcset;
6360 bool normal_dm = draw_mode != dm_alias && draw_mode != dm_cpool && draw_mode != dm_auto;
6361 jwin_draw_frame(menu1,combo_preview2.x-2,combo_preview2.y-2,combo_preview2.w+4,combo_preview2.h+4, FR_DEEP);
6362 if(NextCombo>0 && normal_dm)
6363 {
6364 put_combo(cycle_preview_bmp,0,0,NextCombo,NextCSet,Flags&(cFLAGS|cWALK),0);
6365
6366 if(Flags&cWALK) put_walkflags(cycle_preview_bmp,0,0,NextCombo,0);
6367
6368 if(Flags&cFLAGS) put_flags(cycle_preview_bmp,0,0,NextCombo,0,cFLAGS,0);
6369
6370 stretch_blit(cycle_preview_bmp, menu1, 0, 0, 16, 16, combo_preview2.x, combo_preview2.y, combo_preview2.w, combo_preview2.h);
6371 }
6372 else
6373 {
6374 if (InvalidBG == 2)
6375 {
6376 draw_checkerboard(menu1, combo_preview2.x, combo_preview2.y, 32);
6377 }
6378 else if(InvalidBG == 1)
6379 {
6380 for(int32_t dy=0; dy<combo_preview2.w; dy++)
6381 {
6382 for(int32_t dx=0; dx<combo_preview2.w; dx++)
6383 {
6384 menu1->line[dy+combo_preview2.y][dx+combo_preview2.x]=vc((((zc_oldrand()%100)/50)?0:8)+(((zc_oldrand()%100)/50)?0:7));
6385 }
6386 }
6387 }
6388 else
6389 {
6390 rectfill(menu1, combo_preview2.x,combo_preview2.y, combo_preview2.x+32,combo_preview2.y+combo_preview2.h,vc(0));
6391 safe_rect(menu1, combo_preview2.x,combo_preview2.y, combo_preview2.x+32,combo_preview2.y+combo_preview2.h,vc(15));
6392 line(menu1, combo_preview2.x,combo_preview2.y, combo_preview2.x+32,combo_preview2.y+combo_preview2.h,vc(15));
6393 line(menu1, combo_preview2.x,combo_preview2.y+combo_preview2.h, combo_preview2.x+32,combo_preview2.y,vc(15));
6394 }
6395 }
6396
6397 if(normal_dm)
6398 {
6399 char shortbuf[512];
6400 char buf[256];
6401 strcpy(buf,combo_class_buf[combobuf[NextCombo].type].name);
6402 sprintf(comboprev_buf2, "Cycle: %d\nCSet: %d\n%s", NextCombo, NextCSet, buf);
6403 auto ind = strlen(buf)-1;
6404 int x2 = combo_preview_text2.x;
6405 if(x2 + text_length(txfont, buf) > zq_screen_w-2)
6406 {
6407 auto dotlen = text_length(txfont, "..");
6408 x2 += dotlen;
6409 while(x2 + text_length(txfont, buf) > zq_screen_w-2)
6410 {
6411 if(ind < 0) break;
6412 buf[ind--] = '\0';
6413 }
6414 while(ind >= 0 && buf[ind] == ' ')
6415 buf[ind--] = 0; //trim spaces
6416 strcat(buf, "..");
6417 }
6418
6419 sprintf(shortbuf, "Cycle: %d\nCSet: %d\n%s", NextCombo, NextCSet, buf);
6420 textbox_out(menu1,txfont,combo_preview_text2.x,combo_preview_text2.y,jwin_pal[jcBOXFG],jwin_pal[jcBOX],shortbuf,0,&combo_preview_text2);
6421 }
6422 }
6423
6424 font = get_zc_font(font_lfont_l);
6425 bool merged = is_compact ? compact_merged_combopane : large_merged_combopane;
6426 draw_text_button(menu1,combo_merge_btn.x,combo_merge_btn.y,combo_merge_btn.w,combo_merge_btn.h,merged ? "<|>" : ">|<",vc(1),vc(14),0,true);
6427 }
6428 break;
6429 case rFAVORITES:
6430 {
6431 font = get_zc_font(font_lfont_l);
6432
6433 jwin_draw_frame(menu1,favorites_window.x,favorites_window.y,favorites_window.w,favorites_window.h, FR_WIN);
6434 rectfill(menu1,favorites_window.x+2,favorites_window.y+2,favorites_window.x+favorites_window.w-3,favorites_window.y+favorites_window.h-3,jwin_pal[jcBOX]);
6435 jwin_draw_frame(menu1,favorites_list.x-2,favorites_list.y-2,(favorites_list.w*favorites_list.xscale)+4,(favorites_list.h*favorites_list.yscale)+4, FR_DEEP);
6436 rectfill(menu1,favorites_list.x,favorites_list.y,favorites_list.x+(favorites_list.w*favorites_list.xscale)-1,favorites_list.y+(favorites_list.h*favorites_list.yscale)-1,jwin_pal[jcBOXFG]);
6437
6438 textprintf_ex(menu1,get_zc_font(font_lfont_l),favorites_list.x-2,favorites_list.y-15,jwin_pal[jcBOXFG],-1,is_compact ? "Favorites" : "Favorite Combos");
6439 BITMAP* subb = create_bitmap_ex(8,16,16);
6440
6441 for(int32_t col=0; col<favorites_list.w; ++col)
6442 {
6443 for(int32_t row=0; row<favorites_list.h; ++row)
6444 {
6445 auto i = (row*FAVORITECOMBO_PER_ROW)+col+FAVORITECOMBO_PER_PAGE*FavoriteComboPage;
6446 auto& sqr = favorites_list.subsquare(col,row);
6447 if(i >= MAXFAVORITECOMBOS || favorite_combos[i]==-1)
6448 {
6449 if (InvalidBG == 2)
6450 {
6451 draw_checkerboard(menu1, sqr.x, sqr.y, sqr.w);
6452 }
6453 else if(InvalidBG == 1)
6454 {
6455 for(int32_t dy=0; dy<sqr.h; dy++)
6456 {
6457 for(int32_t dx=0; dx<sqr.w; dx++)
6458 {
6459 menu1->line[sqr.y+dy][sqr.x+dx]=vc((((zc_oldrand()%100)/50)?0:8)+(((zc_oldrand()%100)/50)?0:7));
6460 }
6461 }
6462 }
6463 else
6464 {
6465 xout(menu1, sqr.x, sqr.y, sqr.x+sqr.w-1, sqr.y+sqr.h-1, vc(15), vc(0));
6466 }
6467 }
6468 else
6469 {
6470 clear_bitmap(subb);
6471 bool repos = combotile_override_x < 0 && combotile_override_y < 0;
6472
6473 switch(favorite_combo_modes[i])
6474 {
6475 case dm_alias:
6476 draw_combo_alias_thumbnail(subb, &combo_aliases[favorite_combos[i]], 0, 0, 1);
6477 if (ShowFavoriteComboModes)
6478 put_engraving(subb, 0, 0, 0x3E, 1);
6479 break;
6480 case dm_cpool:
6481 {
6482 int32_t cid = -1; int8_t cs = CSet;
6483 combo_pool const& cp = combo_pools[favorite_combos[i]];
6484
6485 if (cp.get_w(cid, cs, 0) && !combobuf[cid].tile)
6486 cid = -1; //no tile to draw
6487 put_combo(subb, 0, 0, cid, cs, 0, 0);
6488 if (ShowFavoriteComboModes)
6489 put_engraving(subb, 0, 0, 0x3D, 1);
6490 break;
6491 }
6492 case dm_auto:
6493 {
6494 int32_t cid = -1; int8_t cs = CSet;
6495 combo_auto const& ca = combo_autos[favorite_combos[i]];
6496
6497 cid = ca.getDisplay();
6498 if (cid == 0)
6499 cid = -1;
6500 put_combo(subb, 0, 0, cid, cs, 0, 0);
6501 if (ShowFavoriteComboModes)
6502 put_engraving(subb, 0, 0, 0x3C, 1);
6503 break;
6504 }
6505 default:
6506 if (repos)
6507 {
6508 combotile_override_x = sqr.x + (sqr.w - 16) / 2;
6509 combotile_override_y = sqr.y + (sqr.h - 16) / 2;
6510 }
6511 put_combo(subb, 0, 0, favorite_combos[i], CSet, Flags & (cFLAGS | cWALK), 0);
6512 if (repos) combotile_override_x = combotile_override_y = -1;
6513 }
6514 stretch_blit(subb, menu1, 0, 0, 16, 16, sqr.x, sqr.y, sqr.w, sqr.h);
6515 }
6516 }
6517 }
6518
6519 destroy_bitmap(subb);
6520
6521 bool zoomed = is_compact ? compact_zoomed_fav : large_zoomed_fav;
6522 if(!is_compact)
6523 textprintf_right_ex(menu1, get_zc_font(font_lfont_l), favorites_pgleft.x - 2, favorites_pgleft.y, jwin_pal[jcBOXFG], -1, "%d/9", FavoriteComboPage + 1);
6524
6525 draw_text_button(menu1, favorites_pgleft.x, favorites_pgleft.y, favorites_pgleft.w, favorites_pgleft.h, is_compact ? "<" : "<-", vc(1), vc(14), 0, true);
6526 draw_text_button(menu1, favorites_pgright.x, favorites_pgright.y, favorites_pgright.w, favorites_pgright.h, is_compact ? ">" : "->", vc(1), vc(14), 0, true);
6527 draw_text_button(menu1,favorites_zoombtn.x,favorites_zoombtn.y,favorites_zoombtn.w,favorites_zoombtn.h,zoomed ? "-" : "+",vc(1),vc(14),0,true);
6528 draw_text_button(menu1,favorites_x.x,favorites_x.y,favorites_x.w,favorites_x.h,"X",vc(1),vc(14),0,true);
6529 draw_text_button(menu1,favorites_infobtn.x,favorites_infobtn.y,favorites_infobtn.w,favorites_infobtn.h,"?",vc(1),vc(14),0,true);
6530 }
6531 break;
6532 case rCOMMANDS:
6533 {
6534 jwin_draw_frame(menu1,commands_window.x,commands_window.y,commands_window.w,commands_window.h, FR_WIN);
6535 rectfill(menu1,commands_window.x+2,commands_window.y+2,commands_window.x+commands_window.w-3,commands_window.y+commands_window.h-3,jwin_pal[jcBOX]);
6536 jwin_draw_frame(menu1,commands_list.x-2,commands_list.y-2,(commands_list.w*commands_list.xscale)+4,(commands_list.h*commands_list.yscale)+4, FR_DEEP);
6537 rectfill(menu1,commands_list.x,commands_list.y,commands_list.x+(commands_list.w*commands_list.xscale)-1,commands_list.y+(commands_list.h*commands_list.yscale)-1,jwin_pal[jcBOXFG]);
6538 font=get_custom_font(CFONT_FAVCMD);
6539
6540 for(int32_t cmd=0; cmd<(commands_list.w*commands_list.h); ++cmd)
6541 {
6542 uint hkey = favorite_commands[cmd];
6543 draw_layer_button(menu1,
6544 (cmd%commands_list.w)*commands_list.xscale+commands_list.x,
6545 (cmd/commands_list.w)*commands_list.yscale+commands_list.y,
6546 commands_list.xscale,
6547 commands_list.yscale,
6548 get_hotkey_name(hkey),
6549 (selected_hotkey(hkey)?D_SELECTED:0) | (disabled_hotkey(hkey)?D_DISABLED:0));
6550 }
6551
6552 font = get_zc_font(font_lfont_l);
6553 if(commands_txt.x > 0)
6554 {
6555 gui_textout_ln(menu1, get_zc_font(font_lfont_l), (ucc*)"Favorite Commands", commands_txt.x, commands_txt.y, jwin_pal[jcBOXFG], -1, 0);
6556 }
6557
6558 bool zoomed = is_compact ? compact_zoomed_cmd : large_zoomed_cmd;
6559 draw_text_button(menu1,commands_zoombtn.x,commands_zoombtn.y,commands_zoombtn.w,commands_zoombtn.h,zoomed ? "-" : "+",vc(1),vc(14),0,true);
6560 draw_text_button(menu1,commands_x.x,commands_x.y,commands_x.w,commands_x.h,"X",vc(1),vc(14),0,true);
6561 draw_text_button(menu1,commands_infobtn.x,commands_infobtn.y,commands_infobtn.w,commands_infobtn.h,"?",vc(1),vc(14),0,true);
6562 }
6563 break;
6564 }
6565 font = tfont;
6566 }
6567
6568 bool pause_refresh = true;
6569 bool is_refreshing = false;
6570 8 void refresh(int32_t flags, bool update)
6571 {
6572
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(pause_refresh) return;
6573 static bool refreshing = false;
6574
6575 bool earlyret = refreshing;
6576 is_refreshing = refreshing = true;
6577 //^ These prevent recursive calls from updating the screen early
6578
6579 bool zoom_delay = (zoomed_minimap && flags != rSCRMAP);
6580 if(zoom_delay)
6581 flags &= ~rSCRMAP;
6582
6583 if(flags&rCLEAR)
6584 {
6585 //magic pink = 0xED
6586 //system black = vc(0)
6587 //Clear a4 menu
6588 clear_to_color(menu1,jwin_pal[jcBOX]);
6589
6590 //Clears should refresh everything!
6591 flags |= rALL;
6592 }
6593
6594 if(flags&rSCRMAP)
6595 draw_screenunit(rSCRMAP,flags);
6596
6597 if(flags&rMAP)
6598 draw_screenunit(rMAP,flags);
6599
6600 if((flags&rCOMBOS) || (draw_mode == dm_cpool && (flags&rFAVORITES)))
6601 draw_screenunit(rCOMBOS,flags);
6602
6603 if(flags&(rCOMBO|rCOMBOS))
6604 draw_screenunit(rCOMBO,flags);
6605
6606 if(flags&rMENU)
6607 drawpanel();
6608
6609 if(flags&rFAVORITES)
6610 draw_screenunit(rFAVORITES,flags);
6611
6612 if(flags&rCOMMANDS)
6613 draw_screenunit(rCOMMANDS,flags);
6614
6615 FONT* tfont = font;
6616 font = get_custom_font(CFONT_GUI);
6617 jwin_draw_frame(menu1,layer_panel.x,layer_panel.y,layer_panel.w,layer_panel.h,FR_DEEP);
6618 rectfill(menu1,layer_panel.x,layer_panel.y,layer_panel.x+layer_panel.w-1,layer_panel.y+layer_panel.h-1,jwin_pal[jcBOX]);
6619
6620 for(int32_t i=0; i<=6; ++i)
6621 {
6622 char tbuf[15];
6623
6624 if(i>0 && Map.CurrScr()->layermap[i-1])
6625 {
6626 if(is_compact)
6627 sprintf(tbuf, "%s%d %d:%02X", (i==2 && Map.CurrScr()->flags7&fLAYER2BG) || (i==3 && Map.CurrScr()->flags7&fLAYER3BG) ? "-":"", i, Map.CurrScr()->layermap[i-1], Map.CurrScr()->layerscreen[i-1]);
6628 else sprintf(tbuf, "%s%d (%d:%02X)", (i==2 && Map.CurrScr()->flags7&fLAYER2BG) || (i==3 && Map.CurrScr()->flags7&fLAYER3BG) ? "-":"", i, Map.CurrScr()->layermap[i-1], Map.CurrScr()->layerscreen[i-1]);
6629 }
6630 else
6631 {
6632 sprintf(tbuf, "%s%d", (i==2 && Map.CurrScr()->flags7&fLAYER2BG) || (i==3 && Map.CurrScr()->flags7&fLAYER3BG) ? "-":"", i);
6633 }
6634
6635 int32_t spacing_offs = is_compact ? 2 : 10;
6636 int32_t rx = (i * (layerpanel_buttonwidth+spacing_offs+layerpanel_checkbox_wid)) + layer_panel.x+(is_compact?2:6);
6637 int32_t ry = layer_panel.y;
6638 auto cbyofs = (layerpanel_buttonheight-layerpanel_checkbox_hei)/2;
6639 draw_layer_button(menu1, rx, ry, layerpanel_buttonwidth, layerpanel_buttonheight, tbuf, CurrentLayer==i? D_SELECTED : (!Map.CurrScr()->layermap[i-1] && i>0) ? D_DISABLED : 0);
6640 draw_checkbox(menu1,rx+layerpanel_buttonwidth+1,ry+cbyofs,layerpanel_checkbox_wid,layerpanel_checkbox_hei,LayerMaskInt[i]!=0);
6641 }
6642
6643 font=tfont;
6644
6645 // } //if(true)
6646 if(zq_showpal)
6647 {
6648 for(int32_t i=0; i<256; i++)
6649 {
6650 rectfill(menu1,((i&15)<<2)+256,((i>>4)<<2)+176,((i&15)<<2)+259,((i>>4)<<2)+179,i);
6651 }
6652 }
6653 { //Show top-left info
6654 size_t maxwid = (mapscreensize*mapscreenbmp->w)-1;
6655 size_t maxhei = (mapscreensize*mapscreenbmp->w);
6656 set_clip_rect(menu1,mapscreen_x,mapscreen_y,mapscreen_x+maxwid-1,mapscreen_y+maxhei-1);
6657 FONT* showfont = get_custom_font(CFONT_INFO);
6658 int showfont_h = text_height(showfont);
6659 int32_t ypos = mapscreen_y;
6660 if(prv_mode)
6661 {
6662 textout_shadowed_ex(menu1,showfont,"Preview Mode",0,ypos,vc(15),vc(0),infobg?vc(0):-1);
6663 ypos += showfont_h+1;
6664 if(prv_twon)
6665 {
6666 textprintf_shadowed_ex(menu1,showfont,0,ypos,vc(15),vc(0),infobg?vc(0):-1,"T Warp=%d tics", Map.get_prvtime());
6667 ypos += showfont_h+1;
6668 }
6669 }
6670 if(ShowFPS)
6671 {
6672 textprintf_shadowed_ex(menu1,showfont,0,ypos,vc(15),vc(0),infobg?vc(0):-1,"FPS: %3d",lastfps);
6673 ypos += showfont_h+1;
6674 }
6675
6676 if(ShowFFScripts && !prv_mode)
6677 {
6678 word c = Map.CurrScr()->numFFC();
6679 for(word i=0; i< c; i++)
6680 {
6681 if(ypos+showfont_h-1 > map_page_bar[0].y)
6682 break;
6683 if(Map.CurrScr()->ffcs[i].script && Map.CurrScr()->ffcs[i].data)
6684 {
6685 textout_shadowed_ex(menu1, showfont, ffcmap[Map.CurrScr()->ffcs[i].script-1].scriptname.substr(0,300).c_str(),0,ypos,vc(showxypos_ffc==i ? 14 : 15),vc(0),infobg?vc(0):-1);
6686 ypos+=showfont_h+1;
6687 }
6688 }
6689 }
6690 clear_clip_rect(menu1);
6691 if(prv_mode)
6692 do_previewtext();
6693 }
6694 // Show Errors & Details
6695 //This includes the presence of: Screen State Carryover, Timed Warp, Maze Path, the 'Sideview Gravity', 'Invisible Player',
6696 //'Save Screen', 'Continue Here' and 'Treat As..' Screen Flags,
6697 // the String, every Room Type and Catch All, and all four Tile and Side Warps.
6698 if(!prv_mode && ShowInfo)
6699 {
6700 int32_t i=0;
6701 char buf[2048];
6702
6703 // Start with general information
6704 if(Map.CurrScr()->flags3&fINVISHERO)
6705 {
6706 sprintf(buf,"Invisible Player");
6707 show_screen_error(buf,i++,vc(15));
6708 }
6709
6710 if(Map.getLayerTargetMap() > 0)
6711 {
6712 Map.setlayertarget(); //Now the text does not carry over when changing maps, but shifting back, it does not **re-appear** until you change screens.
6713 //It was also required to set some updates in onDecMap and onIncMap. #
6714 //This fixes Screen Info not displaying properly when changing maps. -Z
6715 //Needed to refresh the screen info. -Z ( 26th March, 2019 )
6716 int32_t m = Map.getLayerTargetMultiple();
6717 sprintf(buf,"Used as a layer by screen %d:%02X",Map.getLayerTargetMap(),Map.getLayerTargetScr());
6718 char buf2[24];
6719
6720 if(m>0)
6721 {
6722 sprintf(buf2," and %d other%s",m,m>1?"s":"");
6723 strcat(buf,buf2);
6724 }
6725
6726 show_screen_error(buf,i++,vc(15));
6727 }
6728
6729 if(Map.CurrScr()->nextmap)
6730 {
6731 sprintf(buf,"Screen State carries over to %d:%02X",Map.CurrScr()->nextmap,Map.CurrScr()->nextscr);
6732 show_screen_error(buf,i++,vc(15));
6733 }
6734
6735 if(Map.CurrScr()->timedwarptics)
6736 {
6737 sprintf(buf,"%s%sTimed Warp: %s",(Map.CurrScr()->flags4&fTIMEDDIRECT)?"Direct ":"",(Map.CurrScr()->flags5&fRANDOMTIMEDWARP)?"Random ":"",ticksstr(Map.CurrScr()->timedwarptics));
6738 show_screen_error(buf,i++,vc(15));
6739 }
6740
6741 if(Map.CurrScr()->flags&fMAZE)
6742 {
6743 sprintf(buf,"Maze Path: %s (Exit %s)",pathstr(Map.CurrScr()->path),mazedirstr[Map.CurrScr()->exitdir]);
6744 show_screen_error(buf,i++,vc(15));
6745 }
6746
6747 bool continuescreen = false, savecombo = false;
6748
6749 if(Map.CurrScr()->flags4&fAUTOSAVE)
6750 {
6751 sprintf(buf,"Automatic Save%s Screen", (Map.CurrScr()->flags6&fCONTINUEHERE) ? "-Continue":"");
6752 show_screen_error(buf,i++,vc(15));
6753 continuescreen = ((Map.CurrScr()->flags6&fCONTINUEHERE)!=0);
6754 savecombo = true;
6755 }
6756 else if(Map.CurrScr()->flags6&fCONTINUEHERE)
6757 {
6758 sprintf(buf,"Continue Screen");
6759 show_screen_error(buf,i++,vc(15));
6760 continuescreen = true;
6761 }
6762
6763 if(isSideViewGravity())
6764 {
6765 sprintf(buf,"Sideview Gravity");
6766 show_screen_error(buf,i++,vc(15));
6767 }
6768
6769 if(Map.CurrScr()->flags6 & (fCAVEROOM|fDUNGEONROOM))
6770 {
6771 sprintf(buf,"Treat As %s%s Screen", (Map.CurrScr()->flags6&fCAVEROOM) ? "Interior":"NES Dungeon",
6772 (Map.CurrScr()->flags6 & (fCAVEROOM|fDUNGEONROOM)) == (fCAVEROOM|fDUNGEONROOM) ? " or NES Dungeon":"");
6773 show_screen_error(buf,i++,vc(15));
6774 }
6775
6776 if(Map.CurrScr()->oceansfx != 0)
6777 {
6778 sprintf(buf,"Ambient Sound: %s",sfx_string[Map.CurrScr()->oceansfx]);
6779 show_screen_error(buf,i++,vc(15));
6780 }
6781
6782 if(Map.CurrScr()->bosssfx != 0)
6783 {
6784 sprintf(buf,"Boss Roar Sound: %s",sfx_string[Map.CurrScr()->bosssfx]);
6785 show_screen_error(buf,i++,vc(15));
6786 }
6787
6788 if(Map.CurrScr()->str)
6789 {
6790 strncpy(buf,MsgString(Map.CurrScr()->str, true, false),72);
6791 buf[72] = '\0';
6792 char shortbuf[72];
6793 strip_extra_spaces(buf);
6794 shorten_string(shortbuf, buf, get_zc_font(font_lfont_l), 72, 280);
6795 sprintf(buf,"String %s",shortbuf);
6796 show_screen_error(buf,i++,vc(15));
6797 }
6798
6799 if((Map.CurrScr()->flags&fWHISTLE) || (Map.CurrScr()->flags7&fWHISTLEWATER))
6800 {
6801 sprintf(buf,"Whistle ->%s%s%s",(Map.CurrScr()->flags&fWHISTLE)?" Stairs":"",
6802 (Map.CurrScr()->flags&fWHISTLE && Map.CurrScr()->flags7&fWHISTLEWATER)?", ":"",
6803 (Map.CurrScr()->flags7&fWHISTLEWATER)?"Dry Lake":"");
6804 show_screen_error(buf,i++,vc(15));
6805 }
6806
6807 switch(Map.CurrScr()->room)
6808 {
6809 case rSP_ITEM:
6810 sprintf(buf,"Special Item is %s",item_string[Map.CurrScr()->catchall]);
6811 show_screen_error(buf,i++, vc(15));
6812 break;
6813
6814 case rINFO:
6815 {
6816 int32_t shop = Map.CurrScr()->catchall;
6817 sprintf(buf,"Pay For Info: -%d, -%d, -%d",
6818 QMisc.info[shop].price[0],QMisc.info[shop].price[1],QMisc.info[shop].price[2]);
6819 show_screen_error(buf,i++, vc(15));
6820 }
6821 break;
6822
6823 case rMONEY:
6824 sprintf(buf,"Secret Money: %d Rupees",Map.CurrScr()->catchall);
6825 show_screen_error(buf,i++, vc(15));
6826 break;
6827
6828 case rGAMBLE:
6829 show_screen_error("Gamble Room",i++, vc(15));
6830 break;
6831
6832 case rREPAIR:
6833 sprintf(buf,"Door Repair: -%d Rupees",Map.CurrScr()->catchall);
6834 show_screen_error(buf,i++, vc(15));
6835 break;
6836
6837 case rRP_HC:
6838 sprintf(buf,"Take %s or %s", item_string[iRPotion], item_string[iHeartC]);
6839 show_screen_error(buf,i++, vc(15));
6840 break;
6841
6842 case rGRUMBLE:
6843 show_screen_error("Feed the Goriya",i++, vc(15));
6844 break;
6845
6846 case rTRIFORCE:
6847 show_screen_error("Triforce Check",i++, vc(15));
6848 break;
6849
6850 case rP_SHOP:
6851 case rSHOP:
6852 {
6853 int32_t shop = Map.CurrScr()->catchall;
6854 sprintf(buf,"%sShop: ",
6855 Map.CurrScr()->room==rP_SHOP ? "Potion ":"");
6856
6857 for(int32_t j=0; j<3; j++) if(QMisc.shop[shop].item[j]>0) // Print the 3 items and prices
6858 {
6859 strcat(buf,item_string[QMisc.shop[shop].item[j]]);
6860 strcat(buf,":");
6861 char pricebuf[8];
6862 sprintf(pricebuf,"%d",QMisc.shop[shop].price[j]);
6863 strcat(buf,pricebuf);
6864
6865 if(j<2 && QMisc.shop[shop].item[j+1]>0) strcat(buf,", ");
6866 }
6867
6868 show_screen_error(buf,i++, vc(15));
6869 }
6870 break;
6871
6872 case rBOTTLESHOP:
6873 {
6874 int32_t shop = Map.CurrScr()->catchall;
6875 sprintf(buf,"Bottle Shop: ");
6876
6877 for(int32_t j=0; j<3; j++) if(QMisc.bottle_shop_types[shop].fill[j]>0) // Print the 3 fills and prices
6878 {
6879 strcat(buf,QMisc.bottle_types[QMisc.bottle_shop_types[shop].fill[j]-1].name);
6880 strcat(buf,":");
6881 char pricebuf[8];
6882 sprintf(pricebuf,"%d",QMisc.bottle_shop_types[shop].price[j]);
6883 strcat(buf,pricebuf);
6884
6885 if(j<2 && QMisc.bottle_shop_types[shop].fill[j+1]>0) strcat(buf,", ");
6886 }
6887
6888 show_screen_error(buf,i++, vc(15));
6889 }
6890 break;
6891
6892 case rTAKEONE:
6893 {
6894 int32_t shop = Map.CurrScr()->catchall;
6895 sprintf(buf,"Take Only One: %s%s%s%s%s",
6896 QMisc.shop[shop].item[0]<1?"":item_string[QMisc.shop[shop].item[0]],QMisc.shop[shop].item[0]>0?", ":"",
6897 QMisc.shop[shop].item[1]<1?"":item_string[QMisc.shop[shop].item[1]],(QMisc.shop[shop].item[1]>0&&QMisc.shop[shop].item[2]>0)?", ":"",
6898 QMisc.shop[shop].item[2]<1?"":item_string[QMisc.shop[shop].item[2]]);
6899 show_screen_error(buf,i++, vc(15));
6900 }
6901 break;
6902
6903 case rBOMBS:
6904 sprintf(buf,"More Bombs: -%d Rupees",Map.CurrScr()->catchall);
6905 show_screen_error(buf,i++, vc(15));
6906 break;
6907
6908 case rARROWS:
6909 sprintf(buf,"More Arrows: -%d Rupees",Map.CurrScr()->catchall);
6910 show_screen_error(buf,i++, vc(15));
6911 break;
6912
6913 case rSWINDLE:
6914 sprintf(buf,"Leave Life or %d Rupees",Map.CurrScr()->catchall);
6915 show_screen_error(buf,i++, vc(15));
6916 break;
6917
6918 case r10RUPIES:
6919 show_screen_error("10 Rupees",i++, vc(15));
6920 break;
6921
6922 case rGANON:
6923 show_screen_error("Ganon Room",i++, vc(15));
6924 break;
6925
6926 case rZELDA:
6927 show_screen_error("Zelda Room",i++, vc(15));
6928 break;
6929
6930 case rMUPGRADE:
6931 show_screen_error("1/2 Magic Upgrade",i++, vc(15));
6932 break;
6933
6934 case rLEARNSLASH:
6935 show_screen_error("Learn Slash",i++, vc(15));
6936 break;
6937
6938 case rWARP:
6939 sprintf(buf,"3-Stair Warp: Warp Ring %d",Map.CurrScr()->catchall);
6940 show_screen_error(buf,i++, vc(15));
6941 break;
6942 }
6943
6944 bool undercombo = false, warpa = false, warpb = false, warpc = false, warpd = false, warpr = false;
6945
6946 word maxffc = Map.CurrScr()->numFFC();
6947 for(int32_t c=0; c<176+128+1+maxffc; ++c)
6948 {
6949 // Checks both combos, secret combos, undercombos and FFCs
6950 //Fixme:
6951 int32_t ctype =
6952 combobuf[vbound(
6953 (c>=305 ? Map.CurrScr()->ffcs[c-305].data :
6954 c>=304 ? Map.CurrScr()->undercombo :
6955 c>=176 ? Map.CurrScr()->secretcombo[c-176] :
6956 !Map.CurrScr()->valid ? 0 : // Sanity check: does room combo data exist?
6957 Map.CurrScr()->data[c]
6958 ), 0, MAXCOMBOS-1)].type;
6959
6960 if(!undercombo && integrityBoolUnderCombo(Map.CurrScr(),ctype))
6961 {
6962 undercombo = true;
6963 show_screen_error("Under Combo is combo 0",i++, vc(7));
6964 }
6965
6966 // Tile Warp types
6967 switch(ctype)
6968 {
6969 case cSAVE:
6970 case cSAVE2:
6971 if(!savecombo)
6972 {
6973 savecombo = true;
6974
6975 if(integrityBoolSaveCombo(Map.CurrScr(),ctype))
6976 show_screen_error("Save Screen",i++, vc(15));
6977 else
6978 show_screen_error("Save-Continue Screen",i++, vc(15));
6979 }
6980
6981 break;
6982
6983 case cSTAIRR:
6984 case cPITR:
6985 case cSWARPR:
6986 if(!warpr && (Map.CurrScr()->tilewarptype[0]==wtCAVE || Map.CurrScr()->tilewarptype[1]==wtCAVE ||
6987 Map.CurrScr()->tilewarptype[2]==wtCAVE || Map.CurrScr()->tilewarptype[3]==wtCAVE))
6988 {
6989 warpr = true;
6990 show_screen_error("Random Tile Warp contains Cave/Item Cellar",i++, vc(7));
6991 }
6992
6993 break;
6994
6995 case cCAVED:
6996 case cPITD:
6997 case cSTAIRD:
6998 case cCAVE2D:
6999 case cSWIMWARPD:
7000 case cDIVEWARPD:
7001 case cSWARPD:
7002 if(!warpd)
7003 {
7004 warpd = true;
7005 tile_warp_notification(3,buf);
7006 show_screen_error(buf,i++, vc(15));
7007 }
7008
7009 break;
7010
7011 case cCAVEC:
7012 case cPITC:
7013 case cSTAIRC:
7014 case cCAVE2C:
7015 case cSWIMWARPC:
7016 case cDIVEWARPC:
7017 case cSWARPC:
7018 if(!warpc)
7019 {
7020 warpc = true;
7021 tile_warp_notification(2,buf);
7022 show_screen_error(buf,i++, vc(15));
7023 }
7024
7025 break;
7026
7027 case cCAVEB:
7028 case cPITB:
7029 case cSTAIRB:
7030 case cCAVE2B:
7031 case cSWIMWARPB:
7032 case cDIVEWARPB:
7033 case cSWARPB:
7034 if(!warpb)
7035 {
7036 warpb = true;
7037 tile_warp_notification(1,buf);
7038 show_screen_error(buf,i++, vc(15));
7039 }
7040
7041 break;
7042
7043 case cCAVE:
7044 case cPIT:
7045 case cSTAIR:
7046 case cCAVE2:
7047 case cSWIMWARP:
7048 case cDIVEWARP:
7049 case cSWARPA:
7050 if(!warpa)
7051 {
7052 warpa = true;
7053 tile_warp_notification(0,buf);
7054 show_screen_error(buf,i++, vc(15));
7055 }
7056
7057 break;
7058 }
7059 }
7060
7061 int32_t sidewarpnotify = 0;
7062
7063 if(Map.CurrScr()->flags2&wfUP)
7064 {
7065 side_warp_notification(Map.CurrScr()->sidewarpindex&3,0,buf);
7066 show_screen_error(buf,i++, vc(15));
7067 sidewarpnotify|=(1<<(Map.CurrScr()->sidewarpindex&3));
7068 }
7069
7070 if(Map.CurrScr()->flags2&wfDOWN)
7071 {
7072 side_warp_notification((Map.CurrScr()->sidewarpindex>>2)&3,1,buf);
7073 show_screen_error(buf,i++, vc(15));
7074 sidewarpnotify|=(1<<((Map.CurrScr()->sidewarpindex>>2)&3));
7075 }
7076
7077 if(Map.CurrScr()->flags2&wfLEFT)
7078 {
7079 side_warp_notification((Map.CurrScr()->sidewarpindex>>4)&3,2,buf);
7080 show_screen_error(buf,i++, vc(15));
7081 sidewarpnotify|=(1<<((Map.CurrScr()->sidewarpindex>>4)&3));
7082 }
7083
7084 if(Map.CurrScr()->flags2&wfRIGHT)
7085 {
7086 side_warp_notification((Map.CurrScr()->sidewarpindex>>6)&3,3,buf);
7087 show_screen_error(buf,i++, vc(15));
7088 sidewarpnotify|=(1<<((Map.CurrScr()->sidewarpindex>>6)&3));
7089 }
7090
7091 if(!(sidewarpnotify&1) && Map.CurrScr()->timedwarptics)
7092 {
7093 side_warp_notification(0,4,buf); // Timed Warp
7094 show_screen_error(buf,i++, vc(15));
7095 }
7096
7097 // Now for errors
7098 if((Map.CurrScr()->flags4&fSAVEROOM) && !savecombo) show_screen_error("Save Point->Continue Here, but no Save Point combo?",i++, vc(14));
7099
7100 if(integrityBoolEnemiesItem(Map.CurrScr())) show_screen_error("Enemies->Item, but no enemies",i++, vc(7));
7101
7102 if(integrityBoolEnemiesSecret(Map.CurrScr())) show_screen_error("Enemies->Secret, but no enemies",i++, vc(7));
7103
7104 if(integrityBoolStringNoGuy(Map.CurrScr())) show_screen_error("String, but Guy is (none)",i++, vc(14));
7105
7106 if(integrityBoolGuyNoString(Map.CurrScr())) show_screen_error("Non-Fairy Guy, but String is (none)",i++, vc(14));
7107
7108 if(integrityBoolRoomNoGuy(Map.CurrScr())) show_screen_error("Guy is (none)",i++, vc(14));
7109
7110 if(integrityBoolRoomNoString(Map.CurrScr())) show_screen_error("String is (none)",i++, vc(14));
7111
7112 if(integrityBoolRoomNoGuyNoString(Map.CurrScr())) show_screen_error("Guy and String are (none)",i++, vc(14));
7113 }
7114
7115 if(zoom_delay)
7116 draw_screenunit(rSCRMAP,flags);
7117
7118
7119 if(flags&rCLEAR)
7120 {
7121 //Draw the whole gui
7122 blit(menu1,screen,0,0,0,0,zq_screen_w,zq_screen_h);
7123 }
7124 else
7125 {
7126 blit(menu1,screen,0,16,0,16,zq_screen_w,zq_screen_h-16);
7127 blit(menu1,screen,combolist_window.x-64,0,combolist_window.x-64,0,combolist_window.w+64,16);
7128
7129 if(flags&rCOMBO)
7130 blit(menu1,screen,combo_preview.x,combo_preview.y,combo_preview.x,combo_preview.y,combo_preview.w,combo_preview.h);
7131 }
7132
7133 if(earlyret)
7134 return;
7135
7136 //Draw the Main Menu
7137 rectfill(screen,mainbar.x,mainbar.y,mainbar.x+mainbar.w-1,mainbar.y+mainbar.h-1,jwin_pal[jcBOX]);
7138 jwin_draw_frame(screen,mainbar.x,mainbar.y,mainbar.w,mainbar.h,FR_WIN);
7139
7140 FONT* oldfont = font;
7141 font = get_custom_font(CFONT_GUI);
7142
7143 //Drawmode button
7144 draw_text_button(screen,drawmode_btn.x,drawmode_btn.y,drawmode_btn.w,drawmode_btn.h,dm_names[draw_mode],vc(1),vc(14),0,true);
7145 //Compact button
7146 draw_text_button(screen,compactbtn.x, compactbtn.y, compactbtn.w, compactbtn.h, is_compact ? "< Expand" : "> Compact", vc(1),vc(14),0,true);
7147
7148 font = oldfont;
7149
7150 d_nbmenu_proc(MSG_DRAW, &dialogs[0], 0);
7151
7152 ComboBrushPause=0;
7153
7154 SCRFIX();
7155 if(update)
7156 custom_vsync();
7157 is_refreshing = refreshing = false;
7158 8 }
7159
7160 8 static int minimap_tooltip_id = ttip_register_id();
7161
7162 void select_scr()
7163 {
7164 if(Map.getCurrMap()>=Map.getMapCount())
7165 return;
7166
7167 int32_t tempcb=ComboBrush;
7168 ComboBrush=0;
7169
7170 size_and_pos const& real_mini = zoomed_minimap ? real_minimap_zoomed : real_minimap;
7171
7172 //scooby
7173 while(gui_mouse_b())
7174 {
7175 int32_t x=gui_mouse_x();
7176 int32_t y=gui_mouse_y();
7177
7178 int32_t ind = real_mini.rectind(x,y);
7179
7180 if(ind>=MAPSCRS)
7181 ind-=16;
7182
7183 if(ind > -1 && ind != Map.getCurrScr())
7184 {
7185 Map.setCurrScr(ind);
7186 }
7187
7188 custom_vsync();
7189 refresh(rALL);
7190 }
7191
7192 ComboBrush=tempcb;
7193 }
7194
7195 void clear_cpool()
7196 {
7197 for(int32_t i=0; i<MAXFAVORITECOMBOS; ++i)
7198 {
7199 pool_combos[i].clear();
7200 }
7201 pool_dirty = true;
7202 }
7203
7204 bool select_favorite()
7205 {
7206 int32_t tempcb=ComboBrush;
7207 ComboBrush=0;
7208 bool valid=false;
7209
7210 while(gui_mouse_b())
7211 {
7212 valid=false;
7213 int32_t x=gui_mouse_x();
7214
7215 if(x<favorites_list.x)
7216 x=favorites_list.x;
7217
7218 if(x>favorites_list.x+(favorites_list.w*favorites_list.xscale)-1)
7219 x=favorites_list.x+(favorites_list.w*favorites_list.xscale)-1;
7220
7221 int32_t y=gui_mouse_y();
7222
7223 if(y<favorites_list.y)
7224 y=favorites_list.y;
7225
7226 if(y>favorites_list.y+(favorites_list.h*favorites_list.yscale)-1)
7227 y=favorites_list.y+(favorites_list.h*favorites_list.yscale)-1;
7228
7229 int32_t tempc=(((y-favorites_list.y)/favorites_list.yscale)*FAVORITECOMBO_PER_ROW)+((x-favorites_list.x)/favorites_list.xscale) + FAVORITECOMBO_PER_PAGE * FavoriteComboPage;
7230
7231 if(tempc >= MAXFAVORITECOMBOS)
7232 {
7233 //Nothing, invalid
7234 }
7235 else
7236 {
7237 if(favorite_combos[tempc]!=-1)
7238 {
7239 switch(favorite_combo_modes[tempc])
7240 {
7241 case dm_alias:
7242 draw_mode = dm_alias;
7243 combo_apos = favorite_combos[tempc];
7244 break;
7245 case dm_cpool:
7246 draw_mode = dm_cpool;
7247 combo_pool_pos = favorite_combos[tempc];
7248 break;
7249 case dm_auto:
7250 draw_mode = dm_auto;
7251 combo_auto_pos = favorite_combos[tempc];
7252 break;
7253 default:
7254 draw_mode = dm_normal;
7255 Combo = favorite_combos[tempc];
7256 }
7257 if(AutoBrush)
7258 BrushWidth = BrushHeight = 1;
7259 valid=true;
7260 fix_drawing_mode_menu();
7261 }
7262 }
7263
7264 custom_vsync();
7265 refresh(rALL);
7266 }
7267
7268 ComboBrush=tempcb;
7269 return valid;
7270 }
7271
7272 void select_combo(int32_t clist)
7273 {
7274 current_combolist=clist;
7275 int32_t tempcb=ComboBrush;
7276 ComboBrush=0;
7277
7278 int autobrush_cx = -1, autobrush_cy = -1;
7279 int autobrush_first = First[current_combolist];
7280 auto& curlist = combolist[current_combolist];
7281 AutoBrushRevert = (key[KEY_ALT]||key[KEY_ALTGR]);
7282 while(gui_mouse_b())
7283 {
7284 int32_t x=gui_mouse_x();
7285
7286 if(x<curlist.x)
7287 x=curlist.x;
7288
7289 if(x>curlist.x+(curlist.w*curlist.xscale)-1)
7290 x=curlist.x+(curlist.w*curlist.xscale)-1;
7291
7292 int32_t y=gui_mouse_y();
7293
7294 if(y<curlist.y)
7295 y=curlist.y;
7296
7297 if(y>curlist.y+(curlist.h*curlist.yscale)-1)
7298 y=curlist.y+(curlist.h*curlist.yscale)-1;
7299
7300 int cx = ((x-curlist.x)/curlist.xscale), cy = ((y-curlist.y)/curlist.yscale);
7301 if(AutoBrush)
7302 {
7303 if(autobrush_cx < 0)
7304 {
7305 autobrush_cx = cx;
7306 autobrush_cy = cy;
7307 }
7308 BrushWidth = vbound(abs(autobrush_cx-cx)+1,1,16);
7309 BrushHeight = vbound(abs(autobrush_cy-cy)+1,1,11);
7310 cx = std::min(autobrush_cx,cx);
7311 cy = std::min(autobrush_cy,cy);
7312 }
7313 Combo=(cy*curlist.w)+cx+First[current_combolist];
7314 custom_vsync();
7315 refresh(rALL);
7316 if(AutoBrush) //Prevent any scrolling
7317 First[current_combolist] = autobrush_first;
7318 }
7319 if(key[KEY_ALT]||key[KEY_ALTGR])
7320 AutoBrushRevert = true;
7321 position_mouse_z(0);
7322 ComboBrush=tempcb;
7323 }
7324
7325 void select_comboa(int32_t clist)
7326 {
7327 current_comboalist=clist;
7328 int32_t tempcb=ComboBrush;
7329 ComboBrush=0;
7330 alias_cset_mod=0;
7331
7332 auto& curlist = comboaliaslist[current_comboalist];
7333 while(gui_mouse_b())
7334 {
7335 int32_t x=gui_mouse_x();
7336
7337 if(x<curlist.x)
7338 x=curlist.x;
7339
7340 if(x>curlist.x+(curlist.w*curlist.xscale)-1)
7341 x=curlist.x+(curlist.w*curlist.xscale)-1;
7342
7343 int32_t y=gui_mouse_y();
7344
7345 if(y<curlist.y)
7346 y=curlist.y;
7347
7348 if(y>curlist.y+(curlist.h*curlist.yscale)-1)
7349 y=curlist.y+(curlist.h*curlist.yscale)-1;
7350
7351 combo_apos=(((y-curlist.y)/curlist.yscale)*curlist.w)+((x-curlist.x)/curlist.xscale)+combo_alistpos[current_comboalist];
7352 custom_vsync();
7353 refresh(rALL);
7354 }
7355
7356 ComboBrush=tempcb;
7357 }
7358
7359 void select_combop(int32_t clist)
7360 {
7361 current_cpoollist=clist;
7362 int32_t tempcb=ComboBrush;
7363 ComboBrush=0;
7364
7365 auto& curlist = comboaliaslist[current_cpoollist];
7366 while(gui_mouse_b())
7367 {
7368 int32_t x=gui_mouse_x();
7369
7370 if(x<curlist.x) x=curlist.x;
7371
7372 if(x>curlist.x+(curlist.w*curlist.xscale)-1)
7373 x=curlist.x+(curlist.w*curlist.xscale)-1;
7374
7375 int32_t y=gui_mouse_y();
7376
7377 if(y<curlist.y) y=curlist.y;
7378
7379 if(y>curlist.y+(curlist.h*curlist.yscale)-1)
7380 y=curlist.y+(curlist.h*curlist.yscale)-1;
7381
7382 combo_pool_pos=(((y-curlist.y)/curlist.yscale)*curlist.w)+((x-curlist.x)/curlist.xscale)+combo_pool_listpos[current_cpoollist];
7383 custom_vsync();
7384 refresh(rALL);
7385 }
7386
7387 ComboBrush=tempcb;
7388 }
7389
7390 void select_autocombo(int32_t clist)
7391 {
7392 current_cautolist = clist;
7393 int32_t tempcb = ComboBrush;
7394 ComboBrush = 0;
7395
7396 auto& curlist = comboaliaslist[current_cautolist];
7397 while (gui_mouse_b())
7398 {
7399 int32_t x = gui_mouse_x();
7400
7401 if (x < curlist.x) x = curlist.x;
7402
7403 if (x > curlist.x + (curlist.w * curlist.xscale) - 1)
7404 x = curlist.x + (curlist.w * curlist.xscale) - 1;
7405
7406 int32_t y = gui_mouse_y();
7407
7408 if (y < curlist.y) y = curlist.y;
7409
7410 if (y > curlist.y + (curlist.h * curlist.yscale) - 1)
7411 y = curlist.y + (curlist.h * curlist.yscale) - 1;
7412
7413 combo_auto_pos = (((y - curlist.y) / curlist.yscale) * curlist.w) + ((x - curlist.x) / curlist.xscale) + combo_auto_listpos[current_cautolist];
7414 cauto_height = combo_autos[combo_auto_pos].getArg() + 1;
7415 custom_vsync();
7416 refresh(rALL);
7417 }
7418
7419 ComboBrush = tempcb;
7420 }
7421
7422 void update_combobrush()
7423 {
7424 clear_bitmap(brushbmp);
7425
7426 if(draw_mode==dm_alias)
7427 {
7428 //int32_t count=(combo_aliases[combo_apos].width+1)*(combo_aliases[combo_apos].height+1)*(comboa_lmasktotal(combo_aliases[combo_apos].layermask));
7429 for(int32_t z=0; z<=comboa_lmasktotal(combo_aliases[combo_apos].layermask); z++)
7430 {
7431 for(int32_t y=0; y<=combo_aliases[combo_apos].height; y++)
7432 {
7433 for(int32_t x=0; x<=combo_aliases[combo_apos].width; x++)
7434 {
7435 int32_t position = ((y*(combo_aliases[combo_apos].width+1))+x)+((combo_aliases[combo_apos].width+1)*(combo_aliases[combo_apos].height+1)*z);
7436
7437 if(combo_aliases[combo_apos].combos[position])
7438 {
7439 if(z==0)
7440 {
7441 putcombo(brushbmp,x<<4,y<<4,combo_aliases[combo_apos].combos[position],wrap(combo_aliases[combo_apos].csets[position]+alias_cset_mod, 0, 13));
7442 }
7443 else
7444 {
7445 overcombo(brushbmp,x<<4,y<<4,combo_aliases[combo_apos].combos[position],wrap(combo_aliases[combo_apos].csets[position]+alias_cset_mod, 0, 13));
7446 }
7447 }
7448 }
7449 }
7450 }
7451
7452 switch(alias_origin)
7453 {
7454 case 0:
7455 //if(!(combo_aliases[combo_apos].combos[0]))
7456 textprintf_shadowed_ex(brushbmp, get_zc_font(font_sfont), 6, 6, vc(15), vc(0), -1, "x");
7457 break;
7458
7459 case 1:
7460 //if(!(combo_aliases[combo_apos].combos[combo_aliases[combo_apos].width]))
7461 textprintf_shadowed_ex(brushbmp, get_zc_font(font_sfont), 6+(combo_aliases[combo_apos].width*16), 6, vc(15), vc(0), -1, "x");
7462 break;
7463
7464 case 2:
7465 //if(!(combo_aliases[combo_apos].combos[(combo_aliases[combo_apos].width+1)*combo_aliases[combo_apos].height]))
7466 textprintf_shadowed_ex(brushbmp, get_zc_font(font_sfont), 6, 6+(combo_aliases[combo_apos].height*16), vc(15), vc(0), -1, "x");
7467 break;
7468
7469 case 3:
7470 //if(!(combo_aliases[combo_apos].combos[(combo_aliases[combo_apos].width+1)*(combo_aliases[combo_apos].height)-1]))
7471 textprintf_shadowed_ex(brushbmp, get_zc_font(font_sfont), 6+(combo_aliases[combo_apos].width*16), 6+(combo_aliases[combo_apos].height*16), vc(15), vc(0), -1, "x");
7472 break;
7473 }
7474 }
7475 else if(draw_mode != dm_cpool)
7476 {
7477 int32_t cid = combobrushoverride > -1 ? combobrushoverride : Combo;
7478 if(combo_cols==false)
7479 {
7480 for(int32_t i=0; i<256; i++)
7481 {
7482 if(unsigned(cid+i) >= MAXCOMBOS) break;
7483 if(((i%COMBOS_PER_ROW)<BrushWidth)&&((i/COMBOS_PER_ROW)<BrushHeight))
7484 {
7485 put_combo(brushbmp,(i%COMBOS_PER_ROW)<<4,(i/COMBOS_PER_ROW)<<4,cid+i,CSet,Flags&(cFLAGS|cWALK),0);
7486 }
7487 }
7488 }
7489 else
7490 {
7491 int32_t c = 0;
7492
7493 for(int32_t i=0; i<256; i++)
7494 {
7495 if(unsigned(cid+c) >= MAXCOMBOS) break;
7496 if(((i%COMBOS_PER_ROW)<BrushWidth)&&((i/COMBOS_PER_ROW)<BrushHeight))
7497 {
7498 put_combo(brushbmp,(i%COMBOS_PER_ROW)<<4,(i/COMBOS_PER_ROW)<<4,cid+c,CSet,Flags&(cFLAGS|cWALK),0);
7499 }
7500
7501 if(((cid+c)&3)==3)
7502 c+=48;
7503
7504 ++c;
7505
7506 if((i%COMBOS_PER_ROW)==(COMBOS_PER_ROW-1))
7507 c-=256;
7508 }
7509 }
7510 }
7511 }
7512
7513 byte relational_source_grid[256]=
7514 {
7515 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
7516 16, 16, 17, 17, 18, 18, 19, 19, 16, 16, 17, 17, 18, 18, 19, 19,
7517 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23,
7518 24, 24, 24, 24, 25, 25, 25, 25, 24, 24, 24, 24, 25, 25, 25, 25,
7519 26, 27, 26, 27, 26, 27, 26, 27, 28, 29, 28, 29, 28, 29, 28, 29,
7520 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
7521 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
7522 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
7523 34, 35, 36, 37, 34, 35, 36, 37, 34, 35, 36, 37, 34, 35, 36, 37,
7524 38, 38, 39, 39, 38, 38, 39, 39, 38, 38, 39, 39, 38, 38, 39, 39,
7525 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
7526 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
7527 42, 43, 42, 43, 42, 43, 42, 43, 42, 43, 42, 43, 42, 43, 42, 43,
7528 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
7529 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
7530 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46
7531 };
7532
7533 void draw_autocombo(int32_t pos, bool rclick, bool pressframe)
7534 {
7535 int32_t cid = Combo;
7536 int8_t cs = CSet;
7537 combo_auto &ca = combo_autos[combo_auto_pos];
7538
7539 int32_t scr = Map.getCurrScr();
7540 if (ca.valid())
7541 {
7542 switch (ca.getType())
7543 {
7544 case AUTOCOMBO_BASIC:
7545 {
7546 AutoPattern::autopattern_basic ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7547 if (rclick)
7548 ap.erase(scr, pos);
7549 else
7550 ap.execute(scr, pos);
7551 break;
7552 }
7553 case AUTOCOMBO_Z1:
7554 {
7555 AutoPattern::autopattern_flatmtn ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7556 if (rclick)
7557 ap.erase(scr, pos);
7558 else
7559 ap.execute(scr, pos);
7560 break;
7561 }
7562 case AUTOCOMBO_FENCE:
7563 {
7564 AutoPattern::autopattern_fence ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7565 if (rclick)
7566 ap.erase(scr, pos);
7567 else
7568 ap.execute(scr, pos);
7569 break;
7570 }
7571 case AUTOCOMBO_Z4:
7572 {
7573 AutoPattern::autopattern_cakemtn ap(ca.getType(), CurrentLayer, scr, pos, &ca, cauto_height);
7574 if (rclick)
7575 ap.erase(scr, pos);
7576 else
7577 ap.execute(scr, pos);
7578 break;
7579 }
7580 case AUTOCOMBO_RELATIONAL:
7581 {
7582 AutoPattern::autopattern_relational ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7583 if (rclick)
7584 ap.erase(scr, pos);
7585 else
7586 ap.execute(scr, pos);
7587 break;
7588 }
7589 case AUTOCOMBO_DGNCARVE:
7590 {
7591 AutoPattern::autopattern_dungeoncarve ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7592 if (rclick)
7593 ap.erase(scr, pos);
7594 else
7595 ap.execute(scr, pos);
7596 break;
7597 }
7598 case AUTOCOMBO_DOR:
7599 {
7600 AutoPattern::autopattern_dormtn ap(ca.getType(), CurrentLayer, scr, pos, &ca, cauto_height);
7601 if (rclick)
7602 ap.erase(scr, pos);
7603 else
7604 ap.execute(scr, pos);
7605 break;
7606 }
7607 case AUTOCOMBO_TILING:
7608 {
7609 if (pressframe && (key[KEY_LSHIFT] || key[KEY_RSHIFT]))
7610 {
7611 int32_t x = (scr % 16) * 16 + (pos % 16);
7612 int32_t y = (scr / 16) * 11 + (pos / 16);
7613 byte w = (ca.getArg() & 0xF) + 1;
7614 byte h = ((ca.getArg() >> 4) & 0xF) + 1;
7615 ca.setOffsets(x % w, y % h);
7616 }
7617 AutoPattern::autopattern_tiling ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7618 if (rclick)
7619 ap.erase(scr, pos);
7620 else
7621 ap.execute(scr, pos);
7622 break;
7623 }
7624 case AUTOCOMBO_REPLACE:
7625 {
7626 AutoPattern::autopattern_replace ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7627 if (rclick)
7628 ap.erase(scr, pos);
7629 else
7630 ap.execute(scr, pos);
7631 break;
7632 }
7633 }
7634 }
7635 else
7636 {
7637 ca.updateValid();
7638 if(!ca.valid())
7639 InfoDialog("Notice", "The autocombo you're trying to use is invalid. Reason:"
7640 + ca.getInvalidReason()).show();
7641 }
7642 }
7643
7644 void draw_autocombo_command(int32_t pos, int32_t cmd, int32_t arg)
7645 {
7646 int32_t cid = Combo;
7647 int8_t cs = CSet;
7648 combo_auto ca = combo_autos[combo_auto_pos];
7649
7650 int32_t scr = Map.getCurrScr();
7651 if (ca.valid())
7652 {
7653 switch (ca.getType())
7654 {
7655 case AUTOCOMBO_FENCE:
7656 {
7657 AutoPattern::autopattern_fence ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7658 ap.flip_all_connected(scr, pos, 2048);
7659 break;
7660 }
7661 case AUTOCOMBO_Z4:
7662 {
7663 AutoPattern::autopattern_cakemtn ap(ca.getType(), CurrentLayer, scr, pos, &ca, cauto_height);
7664 switch (cmd)
7665 {
7666 case 0: // Flip
7667 ap.flip_all_connected(scr, pos, 2048);
7668 break;
7669 case 1: // Grow
7670 ap.resize_connected(scr, pos, 2048, vbound(arg, 1, 9));
7671 break;
7672 }
7673 }
7674 }
7675 }
7676 }
7677
7678 int32_t get_autocombo_floating_cid(int32_t pos, bool clicked)
7679 {
7680 combo_auto& ca = combo_autos[combo_auto_pos];
7681
7682 int32_t scr = Map.getCurrScr();
7683 int32_t cid = 0;
7684 if (ca.valid() && mousecomboposition > -1)
7685 {
7686 switch (ca.getType())
7687 {
7688 case AUTOCOMBO_BASIC:
7689 {
7690 AutoPattern::autopattern_basic ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7691 cid = ap.get_floating_cid(scr, pos);
7692 break;
7693 }
7694
7695 case AUTOCOMBO_Z1:
7696 {
7697 AutoPattern::autopattern_flatmtn ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7698 cid = ap.get_floating_cid(scr, pos);
7699 break;
7700 }
7701 case AUTOCOMBO_FENCE:
7702 {
7703 AutoPattern::autopattern_fence ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7704 cid = ap.get_floating_cid(scr, pos);
7705 break;
7706 }
7707 case AUTOCOMBO_Z4:
7708 {
7709 AutoPattern::autopattern_cakemtn ap(ca.getType(), CurrentLayer, scr, pos, &ca, cauto_height);
7710 cid = ap.get_floating_cid(scr, pos);
7711 break;
7712 }
7713 case AUTOCOMBO_RELATIONAL:
7714 {
7715 AutoPattern::autopattern_relational ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7716 cid = ap.get_floating_cid(scr, pos);
7717 break;
7718 }
7719 case AUTOCOMBO_DGNCARVE:
7720 {
7721 AutoPattern::autopattern_dungeoncarve ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7722 cid = ap.get_floating_cid(scr, pos);
7723 break;
7724 }
7725 case AUTOCOMBO_DOR:
7726 {
7727 AutoPattern::autopattern_dormtn ap(ca.getType(), CurrentLayer, scr, pos, &ca, cauto_height);
7728 cid = ap.get_floating_cid(scr, pos);
7729 break;
7730 }
7731 case AUTOCOMBO_TILING:
7732 {
7733 std::pair<byte, byte> offs = ca.getOffsets();
7734 if (!clicked && (key[KEY_LSHIFT] || key[KEY_RSHIFT]))
7735 {
7736 int32_t x = (scr % 16) * 16 + (pos % 16);
7737 int32_t y = (scr / 16) * 11 + (pos / 16);
7738 byte w = (ca.getArg() & 0xF) + 1;
7739 byte h = ((ca.getArg() >> 4) & 0xF) + 1;
7740 offs.first = (x % w);
7741 offs.second = (y % h);
7742 }
7743 AutoPattern::autopattern_tiling ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7744 cid = ap.get_floating_cid(scr, pos);
7745 break;
7746 }
7747 case AUTOCOMBO_REPLACE:
7748 {
7749 AutoPattern::autopattern_replace ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7750 cid = ap.get_floating_cid(scr, pos);
7751 break;
7752 }
7753 }
7754 }
7755 return cid;
7756 }
7757
7758 void change_autocombo_height(int32_t change)
7759 {
7760 bool can_change = false;
7761 if (draw_mode == dm_auto)
7762 {
7763 combo_auto ca = combo_autos[combo_auto_pos];
7764 switch (ca.getType())
7765 {
7766 case AUTOCOMBO_Z4:
7767 can_change = true;
7768 [[fallthrough]];
7769 case AUTOCOMBO_DOR:
7770 break;
7771 default:
7772 return;
7773 }
7774 }
7775 else
7776 return;
7777 int32_t x = gui_mouse_x();
7778 int32_t y = gui_mouse_y();
7779 double startx = mapscreen_x + (showedges ? (16 * mapscreensize) : 0);
7780 double starty = mapscreen_y + (showedges ? (16 * mapscreensize) : 0);
7781 int32_t startxint = mapscreen_x + (showedges ? int32_t(16 * mapscreensize) : 0);
7782 int32_t startyint = mapscreen_y + (showedges ? int32_t(16 * mapscreensize) : 0);
7783
7784 if (can_change && isinRect(x, y, startxint, startyint, int32_t(startx + (256 * mapscreensize) - 1), int32_t(starty + (176 * mapscreensize) - 1)))
7785 {
7786 Map.StartListCommand();
7787 int32_t cxstart = (x - startxint) / int32_t(16 * mapscreensize);
7788 int32_t cystart = (y - startyint) / int32_t(16 * mapscreensize);
7789 int32_t cstart = (cystart * 16) + cxstart;
7790 draw_autocombo_command(cstart, 1, cauto_height + change);
7791 Map.FinishListCommand();
7792 }
7793 cauto_height = vbound(cauto_height + change, 1, 9);
7794 }
7795
7796 void draw(bool justcset)
7797 {
7798 combo_pool const& pool = combo_pools[combo_pool_pos];
7799 if(draw_mode == dm_cpool && !pool.valid())
7800 return;
7801 saved=false;
7802 int32_t drawmap, drawscr;
7803
7804 if(CurrentLayer==0)
7805 {
7806 drawmap=Map.getCurrMap();
7807 drawscr=Map.getCurrScr();
7808 }
7809 else
7810 {
7811 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
7812 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
7813 }
7814
7815 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
7816 if(!draw_mapscr) return;
7817 if(!(draw_mapscr->valid&mVALID))
7818 {
7819 Map.CurrScr()->valid|=mVALID;
7820 draw_mapscr->valid|=mVALID;
7821 Map.setcolor(Color);
7822 }
7823
7824 refresh(rMAP+rSCRMAP);
7825 int32_t lastpos = -1;
7826
7827 std::shared_ptr<tile_grid_draw_command> dungeon_draw_cmd;
7828 if (draw_mode == dm_relational || draw_mode == dm_dungeon)
7829 {
7830 dungeon_draw_cmd = std::make_shared<tile_grid_draw_command>();
7831 util::copy_2d_array<byte, 15, 20>(relational_tile_grid, dungeon_draw_cmd->prev_tile_grid);
7832 }
7833
7834 Map.StartListCommand();
7835 bool pressframe = true;
7836 while(gui_mouse_b())
7837 {
7838 int32_t x=gui_mouse_x();
7839 int32_t y=gui_mouse_y();
7840 double startx=mapscreen_x+(showedges?(16*mapscreensize):0);
7841 double starty=mapscreen_y+(showedges?(16*mapscreensize):0);
7842 int32_t startxint=mapscreen_x+(showedges?int32_t(16*mapscreensize):0);
7843 int32_t startyint=mapscreen_y+(showedges?int32_t(16*mapscreensize):0);
7844
7845 if(isinRect(x,y,startxint,startyint,int32_t(startx+(256*mapscreensize)-1),int32_t(starty+(176*mapscreensize)-1)))
7846 {
7847 int32_t cxstart=(x-startxint)/int32_t(16*mapscreensize);
7848 int32_t cystart=(y-startyint)/int32_t(16*mapscreensize);
7849 int32_t cstart=(cystart*16)+cxstart;
7850 if (pressframe)
7851 {
7852 lastpos = cstart;
7853 }
7854 else if(cstart == lastpos)
7855 {
7856 custom_vsync();
7857 refresh(rALL);
7858 continue;
7859 }
7860 else if(draw_mode == dm_auto)
7861 {
7862 if (combo_autos[combo_auto_pos].getType() == AUTOCOMBO_FENCE || combo_autos[combo_auto_pos].getType() == AUTOCOMBO_Z4)
7863 {
7864 bool did_diag = false;
7865 // Don't allow moving the brush at anything but cardinal directions while in these modes
7866 switch (cstart - lastpos)
7867 {
7868 case -1:
7869 case 1:
7870 case -16:
7871 case 16:
7872 break;
7873 default:
7874 did_diag = true;
7875 }
7876 if (did_diag)
7877 {
7878 int32_t oldx = lastpos % 16;
7879 int32_t oldy = lastpos / 16;
7880 int32_t cx = (oldx * 16 * mapscreensize) + 8;
7881 int32_t cy = (oldy * 16 * mapscreensize) + 8;
7882 int32_t nx = x - startxint;
7883 int32_t ny = y - startyint;
7884 if (std::abs(nx - cx) < std::abs(ny - cy))
7885 {
7886 oldy = vbound(oldy + ((ny - cy) < 0 ? -1 : 1), 0, 11);
7887 }
7888 else
7889 {
7890 oldx = vbound(oldx + ((nx - cx) < 0 ? -1 : 1), 0, 15);
7891 }
7892 cstart = (oldy * 16) + oldx;
7893 }
7894 }
7895 }
7896 lastpos = cstart;
7897
7898 switch(draw_mode)
7899 {
7900 case dm_normal:
7901 {
7902 int32_t cc=Combo;
7903
7904 if(!combo_cols)
7905 {
7906 for(int32_t cy=0; cy+cystart<11&&cy<BrushHeight; cy++)
7907 {
7908 for(int32_t cx=0; cx+cxstart<16&&cx<BrushWidth; cx++)
7909 {
7910 int32_t c=cstart+(cy*16)+cx;
7911 Map.DoSetComboCommand(drawmap, drawscr, c, justcset ? -1 : (cc + cx), CSet);
7912 }
7913
7914 cc+=20;
7915 }
7916 }
7917 else
7918 {
7919 for(int32_t cy=0; cy+cystart<11&&cy<BrushHeight; cy++)
7920 {
7921 for(int32_t cx=0; cx+cxstart<16&&cx<BrushWidth; cx++)
7922 {
7923 int32_t c=cstart+(cy*16)+cx;
7924 cc=Combo + cx + cy*4;
7925 Map.DoSetComboCommand(drawmap, drawscr, c, justcset ? -1 : cc, CSet);
7926 }
7927 }
7928 }
7929
7930 update_combobrush();
7931 }
7932 break;
7933 case dm_cpool:
7934 {
7935 int32_t cid = Combo;
7936 int8_t cs = CSet;
7937 pool.pick(cid,cs);
7938
7939 if(!combo_cols)
7940 {
7941 auto cid2 = cid;
7942 for(int32_t cy=0; cy+cystart<11&&cy<BrushHeight; cy++)
7943 {
7944 for(int32_t cx=0; cx+cxstart<16&&cx<BrushWidth; cx++)
7945 {
7946 int32_t c=cstart+(cy*16)+cx;
7947 Map.DoSetComboCommand(drawmap, drawscr, c, justcset ? -1 : (cid2 + cx), cs);
7948 }
7949
7950 cid2+=20;
7951 }
7952 }
7953 else
7954 {
7955 for(int32_t cy=0; cy+cystart<11&&cy<BrushHeight; cy++)
7956 {
7957 for(int32_t cx=0; cx+cxstart<16&&cx<BrushWidth; cx++)
7958 {
7959 int32_t c=cstart+(cy*16)+cx;
7960 auto cid2=cid + cx + cy*4;
7961 Map.DoSetComboCommand(drawmap, drawscr, c, justcset ? -1 : cid2, cs);
7962 }
7963 }
7964 }
7965
7966 update_combobrush();
7967 }
7968 break;
7969
7970 case dm_relational:
7971 {
7972 int32_t c2,c3;
7973 int32_t cx, cy, cx2, cy2;
7974 cy=cstart>>4;
7975 cx=cstart&15;
7976
7977 if(key[KEY_LSHIFT]||key[KEY_RSHIFT])
7978 {
7979 relational_tile_grid[(cy+rtgyo)][cx+rtgxo]=1;
7980 Map.DoSetComboCommand(drawmap, drawscr, cstart, Combo+47, CSet);
7981 }
7982 else
7983 {
7984 relational_tile_grid[(cy+rtgyo)][cx+rtgxo]=0;
7985 }
7986
7987 for(int32_t y2=-1; y2<2; ++y2)
7988 {
7989 cy2=cy+y2;
7990
7991 if((cy2>11)||(cy2<0))
7992 {
7993 continue;
7994 }
7995
7996 for(int32_t x2=-1; x2<2; ++x2)
7997 {
7998 cx2=cx+x2;
7999
8000 if((cx2>15)||(cx2<0))
8001 {
8002 continue;
8003 }
8004
8005 c2=cstart+(y2*16)+x2;
8006 c3=((relational_tile_grid[((cy2-1)+rtgyo)][(cx2+1)+rtgxo]?1:0)<<0)+
8007 ((relational_tile_grid[((cy2-1)+rtgyo)][(cx2-1)+rtgxo]?1:0)<<1)+
8008 ((relational_tile_grid[((cy2+1)+rtgyo)][(cx2-1)+rtgxo]?1:0)<<2)+
8009 ((relational_tile_grid[((cy2+1)+rtgyo)][(cx2+1)+rtgxo]?1:0)<<3)+
8010 ((relational_tile_grid[((cy2)+rtgyo)][(cx2+1)+rtgxo]?1:0)<<4)+
8011 ((relational_tile_grid[((cy2-1)+rtgyo)][(cx2)+rtgxo]?1:0)<<5)+
8012 ((relational_tile_grid[((cy2)+rtgyo)][(cx2-1)+rtgxo]?1:0)<<6)+
8013 ((relational_tile_grid[((cy2+1)+rtgyo)][(cx2)+rtgxo]?1:0)<<7);
8014
8015 if(relational_tile_grid[((c2>>4)+rtgyo)][(c2&15)+rtgxo]==0)
8016 {
8017 Map.DoSetComboCommand(drawmap, drawscr, c2, Combo+relational_source_grid[c3], CSet);
8018 }
8019 }
8020 }
8021 }
8022 break;
8023
8024 case dm_dungeon:
8025 {
8026 int32_t c2,c3,c4;
8027 int32_t cx, cy, cx2, cy2;
8028 cy=cstart>>4;
8029 cx=cstart&15;
8030
8031 if(key[KEY_LSHIFT]||key[KEY_RSHIFT])
8032 {
8033 relational_tile_grid[(cy+rtgyo)][cx+rtgxo]=0;
8034
8035 for(int32_t y2=-1; y2<2; ++y2)
8036 {
8037 cy2=cy+y2;
8038
8039 if((cy2>11)||(cy2<0))
8040 {
8041 continue;
8042 }
8043
8044 for(int32_t x2=-1; x2<2; ++x2)
8045 {
8046 cx2=cx+x2;
8047
8048 if((cx2>15)||(cx2<0))
8049 {
8050 continue;
8051 }
8052
8053 if(relational_tile_grid[(cy2+rtgyo)][cx2+rtgxo]!=0)
8054 {
8055 relational_tile_grid[(cy2+rtgyo)][cx2+rtgxo]=1;
8056 };
8057 }
8058 }
8059
8060 Map.DoSetComboCommand(drawmap, drawscr, cstart, Combo, CSet);
8061 }
8062 else
8063 {
8064 relational_tile_grid[(cy+rtgyo)][cx+rtgxo]=2;
8065
8066 for(int32_t y2=-1; y2<2; ++y2)
8067 {
8068 cy2=cy+y2;
8069
8070 if((cy2>11)||(cy2<0))
8071 {
8072 continue;
8073 }
8074
8075 for(int32_t x2=-1; x2<2; ++x2)
8076 {
8077 cx2=cx+x2;
8078
8079 if((cx2>15)||(cx2<0))
8080 {
8081 continue;
8082 }
8083
8084 if(relational_tile_grid[(cy2+rtgyo)][cx2+rtgxo]==0)
8085 {
8086 relational_tile_grid[(cy2+rtgyo)][cx2+rtgxo]=1;
8087 };
8088 }
8089 }
8090
8091 Map.DoSetComboCommand(drawmap, drawscr, cstart, Combo+48+47, CSet);
8092 }
8093
8094 for(int32_t y2=0; y2<11; ++y2)
8095 {
8096 for(int32_t x2=0; x2<16; ++x2)
8097 {
8098 c2=(y2*16)+x2;
8099 c4=relational_tile_grid[((y2)+rtgyo)][(x2)+rtgxo];
8100 c3=(((relational_tile_grid[((y2-1)+rtgyo)][(x2+1)+rtgxo]>c4)?1:0)<<0)+
8101 (((relational_tile_grid[((y2-1)+rtgyo)][(x2-1)+rtgxo]>c4)?1:0)<<1)+
8102 (((relational_tile_grid[((y2+1)+rtgyo)][(x2-1)+rtgxo]>c4)?1:0)<<2)+
8103 (((relational_tile_grid[((y2+1)+rtgyo)][(x2+1)+rtgxo]>c4)?1:0)<<3)+
8104 (((relational_tile_grid[((y2)+rtgyo)][(x2+1)+rtgxo]>c4)?1:0)<<4)+
8105 (((relational_tile_grid[((y2-1)+rtgyo)][(x2)+rtgxo]>c4)?1:0)<<5)+
8106 (((relational_tile_grid[((y2)+rtgyo)][(x2-1)+rtgxo]>c4)?1:0)<<6)+
8107 (((relational_tile_grid[((y2+1)+rtgyo)][(x2)+rtgxo]>c4)?1:0)<<7);
8108
8109 if(relational_tile_grid[(y2+rtgyo)][x2+rtgxo]<2)
8110 {
8111 Map.DoSetComboCommand(drawmap, drawscr, c2, Combo+relational_source_grid[c3]+(48*c4), CSet);
8112 }
8113 }
8114 }
8115 }
8116 break;
8117
8118 case dm_alias:
8119 {
8120 combo_alias *combo = &combo_aliases[combo_apos];
8121 if(!combo->layermask)
8122 {
8123 int32_t ox=0, oy=0;
8124
8125 switch(alias_origin)
8126 {
8127 case 0:
8128 ox=0;
8129 oy=0;
8130 break;
8131
8132 case 1:
8133 ox=(combo->width);
8134 oy=0;
8135 break;
8136
8137 case 2:
8138 ox=0;
8139 oy=(combo->height);
8140 break;
8141
8142 case 3:
8143 ox=(combo->width);
8144 oy=(combo->height);
8145 break;
8146 }
8147
8148 for(int32_t cy=0; cy-oy+cystart<11&&cy<=combo->height; cy++)
8149 {
8150 for(int32_t cx=0; cx-ox+cxstart<16&&cx<=combo->width; cx++)
8151 {
8152 if((cx+cxstart-ox>=0)&&(cy+cystart-oy>=0))
8153 {
8154 int32_t c=cstart+((cy-oy)*16)+cx-ox;
8155 int32_t p=(cy*(combo->width+1))+cx;
8156
8157 if(combo->combos[p])
8158 {
8159 Map.DoSetComboCommand(drawmap, drawscr, c, combo->combos[p], wrap(combo->csets[p]+alias_cset_mod, 0, 13));
8160 }
8161 }
8162 }
8163 }
8164 }
8165 else
8166 {
8167 int32_t amap=0, ascr=0;
8168 int32_t lcheck = 1;
8169 int32_t laypos = 0;
8170 int32_t ox=0, oy=0;
8171
8172 switch(alias_origin)
8173 {
8174 case 0:
8175 ox=0;
8176 oy=0;
8177 break;
8178
8179 case 1:
8180 ox=(combo->width);
8181 oy=0;
8182 break;
8183
8184 case 2:
8185 ox=0;
8186 oy=(combo->height);
8187 break;
8188
8189 case 3:
8190 ox=(combo->width);
8191 oy=(combo->height);
8192 break;
8193 }
8194
8195 for(int32_t cz=0; cz<7; cz++, lcheck<<=1)
8196 {
8197 if(!cz)
8198 {
8199 amap = Map.getCurrMap();
8200 ascr = Map.getCurrScr();
8201 }
8202 else
8203 {
8204 if(cz==1) lcheck>>=1;
8205
8206 if(combo->layermask&lcheck)
8207 {
8208 amap = Map.CurrScr()->layermap[cz-1]-1;
8209 ascr = Map.CurrScr()->layerscreen[cz-1];
8210 mapscr* mapscr_ptr = Map.AbsoluteScr(amap, ascr);
8211 if(mapscr_ptr)
8212 mapscr_ptr->valid |= mVALID;
8213 laypos++;
8214 }
8215 }
8216
8217 for(int32_t cy=0; cy-oy+cystart<11&&cy<=combo->height; cy++)
8218 {
8219 for(int32_t cx=0; cx-ox+cxstart<16&&cx<=combo->width; cx++)
8220 {
8221 if((!cz)||/*(Map.CurrScr()->layermap[cz>0?cz-1:0])*/amap>=0)
8222 {
8223 if((cz==0)||(combo->layermask&lcheck))
8224 {
8225 if((cx+cxstart-ox>=0)&&(cy+cystart-oy>=0))
8226 {
8227 int32_t c=cstart+((cy-oy)*16)+cx-ox;
8228 int32_t p=((cy*(combo->width+1))+cx)+((combo->width+1)*(combo->height+1)*laypos);
8229
8230 if((combo->combos[p])&&(amap>=0))
8231 {
8232 Map.DoSetComboCommand(amap, ascr, c, combo->combos[p], wrap(combo->csets[p]+alias_cset_mod, 0, 13));
8233 }
8234 }
8235 }
8236 }
8237 }
8238 }
8239 }
8240 }
8241
8242 break;
8243 }
8244
8245 case dm_auto:
8246 {
8247 draw_autocombo(cstart, gui_mouse_b() & 2, pressframe);
8248
8249 combobrushoverride = get_autocombo_floating_cid(cstart, true);
8250 update_combobrush();
8251 }
8252 }
8253 }
8254 pressframe = false;
8255
8256 custom_vsync();
8257 refresh(rALL);
8258 }
8259
8260 if (dungeon_draw_cmd)
8261 {
8262 util::copy_2d_array<byte, 15, 20>(relational_tile_grid, dungeon_draw_cmd->tile_grid);
8263 Map.ExecuteCommand(dungeon_draw_cmd, true);
8264 }
8265 Map.FinishListCommand();
8266 if(AutoBrushRevert)
8267 {
8268 AutoBrushRevert = false;
8269 BrushWidth = 1;
8270 BrushHeight = 1;
8271 }
8272 }
8273
8274 void replace(int32_t c)
8275 {
8276 int32_t cid = Combo;
8277 int8_t cs = CSet;
8278 combo_pool const& pool = combo_pools[combo_pool_pos];
8279 if(draw_mode == dm_cpool && !pool.valid())
8280 return;
8281
8282 saved=false;
8283 int32_t drawmap, drawscr;
8284
8285 if(CurrentLayer==0)
8286 {
8287 drawmap=Map.getCurrMap();
8288 drawscr=Map.getCurrScr();
8289 }
8290 else
8291 {
8292 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
8293 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
8294 }
8295 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
8296 if(!draw_mapscr) return;
8297
8298 int32_t targetcombo = draw_mapscr->data[c];
8299 int32_t targetcset = draw_mapscr->cset[c];
8300
8301 Map.StartListCommand();
8302 if(key[KEY_LSHIFT] || key[KEY_RSHIFT])
8303 {
8304 for(int32_t i=0; i<176; i++)
8305 {
8306 if((draw_mapscr->cset[i])==targetcset)
8307 {
8308 if(draw_mode == dm_cpool)
8309 pool.pick(cid,cs);
8310 Map.DoSetComboCommand(drawmap, drawscr, i, -1, cs);
8311 }
8312 }
8313 }
8314 else
8315 {
8316 for(int32_t i=0; i<176; i++)
8317 {
8318 if(((draw_mapscr->data[i])==targetcombo) &&
8319 ((draw_mapscr->cset[i])==targetcset))
8320 {
8321 if(draw_mode == dm_cpool)
8322 pool.pick(cid,cs);
8323 Map.DoSetComboCommand(drawmap, drawscr, i, cid, cs);
8324 }
8325 }
8326 }
8327 Map.FinishListCommand();
8328
8329 refresh(rMAP);
8330 }
8331
8332 void draw_block(int32_t start,int32_t w,int32_t h)
8333 {
8334 int32_t cid = Combo;
8335 int8_t cs = CSet;
8336 if(draw_mode == dm_cpool)
8337 {
8338 combo_pool const& pool = combo_pools[combo_pool_pos];
8339 if(!pool.pick(cid,cs)) return;
8340 }
8341 saved=false;
8342 int32_t drawmap, drawscr;
8343
8344 if(CurrentLayer==0)
8345 {
8346 drawmap=Map.getCurrMap();
8347 drawscr=Map.getCurrScr();
8348 }
8349 else
8350 {
8351 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
8352 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
8353 }
8354 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
8355 if(!draw_mapscr) return;
8356
8357 if(!(draw_mapscr->valid&mVALID))
8358 {
8359 Map.CurrScr()->valid|=mVALID;
8360 draw_mapscr->valid|=mVALID;
8361 Map.setcolor(Color);
8362 }
8363
8364 Map.StartListCommand();
8365 for(int32_t y=0; y<h && (y<<4)+start < 176; y++)
8366 for(int32_t x=0; x<w && (start&15)+x < 16; x++)
8367 {
8368 Map.DoSetComboCommand(drawmap, drawscr, start+(y<<4)+x, cid+(y*4)+x, cs);
8369 }
8370
8371 Map.FinishListCommand();
8372 refresh(rMAP+rSCRMAP);
8373 }
8374
8375 static void fill(int32_t map, int32_t screen_index, mapscr* fillscr, int32_t targetcombo, int32_t targetcset, int32_t sx, int32_t sy, int32_t dir, int32_t diagonal, bool only_cset, bool* filled_combos)
8376 {
8377 bool rclick = gui_mouse_b() & 2;
8378 bool ignored_combo = false;
8379
8380 if (filled_combos[(sy << 4) + sx])
8381 return;
8382
8383 if (draw_mode == dm_auto)
8384 {
8385 combo_auto const& cauto = combo_autos[combo_auto_pos];
8386 ignored_combo = cauto.isIgnoredCombo((fillscr->data[((sy << 4) + sx)]));
8387 if (rclick)
8388 {
8389 if (cauto.containsCombo(targetcombo))
8390 {
8391 if (!cauto.containsCombo(fillscr->data[((sy << 4) + sx)]))
8392 return;
8393 if (cauto.getType() == AUTOCOMBO_REPLACE && ignored_combo)
8394 return;
8395 }
8396 else
8397 return;
8398 }
8399 else
8400 {
8401 if ((fillscr->data[((sy<<4)+sx)])!=targetcombo && !ignored_combo)
8402 return;
8403 if (cauto.getType() == AUTOCOMBO_REPLACE && !ignored_combo)
8404 return;
8405 }
8406
8407 if((fillscr->cset[((sy<<4)+sx)])!=targetcset && !ignored_combo)
8408 return;
8409 }
8410 else
8411 {
8412 if(!only_cset)
8413 {
8414 if((fillscr->data[((sy<<4)+sx)])!=targetcombo)
8415 return;
8416 }
8417
8418 if((fillscr->cset[((sy<<4)+sx)])!=targetcset)
8419 return;
8420 }
8421
8422 int32_t cid = Combo;
8423 int8_t cs = CSet;
8424 if(draw_mode == dm_cpool)
8425 {
8426 combo_pool const& pool = combo_pools[combo_pool_pos];
8427 if(!pool.pick(cid,cs)) return;
8428 }
8429 else if (draw_mode == dm_auto)
8430 {
8431 combo_auto const& cauto = combo_autos[combo_auto_pos];
8432 if (!cauto.valid())
8433 return;
8434 if (!rclick && (cauto.containsCombo(targetcombo) && !ignored_combo))
8435 return;
8436 if (rclick && cauto.getEraseCombo() == targetcombo)
8437 return;
8438 }
8439
8440 filled_combos[(sy << 4) + sx] = true;
8441
8442 if (draw_mode == dm_auto)
8443 {
8444 draw_autocombo((sy << 4) + sx, rclick);
8445 }
8446 else
8447 Map.DoSetComboCommand(map, screen_index, (sy<<4)+sx, only_cset ? -1 : cid, cs);
8448
8449 if((sy>0) && (dir!=down)) // && ((Map.CurrScr()->data[(((sy-1)<<4)+sx)]&0x7FF)==target))
8450 fill(map, screen_index, fillscr, targetcombo, targetcset, sx, sy-1, up, diagonal, only_cset, filled_combos);
8451
8452 if((sy<10) && (dir!=up)) // && ((Map.CurrScr()->data[(((sy+1)<<4)+sx)]&0x7FF)==target))
8453 fill(map, screen_index, fillscr, targetcombo, targetcset, sx, sy+1, down, diagonal, only_cset, filled_combos);
8454
8455 if((sx>0) && (dir!=right)) // && ((Map.CurrScr()->data[((sy<<4)+sx-1)]&0x7FF)==target))
8456 fill(map, screen_index, fillscr, targetcombo, targetcset, sx-1, sy, left, diagonal, only_cset, filled_combos);
8457
8458 if((sx<15) && (dir!=left)) // && ((Map.CurrScr()->data[((sy<<4)+sx+1)]&0x7FF)==target))
8459 fill(map, screen_index, fillscr, targetcombo, targetcset, sx+1, sy, right, diagonal, only_cset, filled_combos);
8460
8461 if(diagonal==1)
8462 {
8463 if((sy>0) && (sx>0) && (dir!=r_down)) // && ((Map.CurrScr()->data[(((sy-1)<<4)+sx-1)]&0x7FF)==target))
8464 fill(map, screen_index, fillscr, targetcombo, targetcset, sx-1, sy-1, l_up, diagonal, only_cset, filled_combos);
8465
8466 if((sy<10) && (sx<15) && (dir!=l_up)) // && ((Map.CurrScr()->data[(((sy+1)<<4)+sx+1)]&0x7FF)==target))
8467 fill(map, screen_index, fillscr, targetcombo, targetcset, sx+1, sy+1, r_down, diagonal, only_cset, filled_combos);
8468
8469 if((sx>0) && (sy<10) && (dir!=r_up)) // && ((Map.CurrScr()->data[(((sy+1)<<4)+sx-1)]&0x7FF)==target))
8470 fill(map, screen_index, fillscr, targetcombo, targetcset, sx-1, sy+1, l_down, diagonal, only_cset, filled_combos);
8471
8472 if((sx<15) && (sy>0) && (dir!=l_down)) // && ((Map.CurrScr()->data[(((sy-1)<<4)+sx+1)]&0x7FF)==target))
8473 fill(map, screen_index, fillscr, targetcombo, targetcset, sx+1, sy-1, r_up, diagonal, only_cset, filled_combos);
8474 }
8475 }
8476
8477 static void fill_flag(int32_t map, int32_t screen_index, mapscr* fillscr, int32_t targetflag, int32_t sx, int32_t sy, int32_t dir, int32_t diagonal)
8478 {
8479 if((fillscr->sflag[((sy<<4)+sx)])!=targetflag)
8480 return;
8481
8482 Map.DoSetFlagCommand(map, screen_index, (sy<<4)+sx, Flag);
8483
8484 if((sy>0) && (dir!=down))
8485 fill_flag(map, screen_index, fillscr, targetflag, sx, sy-1, up, diagonal);
8486
8487 if((sy<10) && (dir!=up))
8488 fill_flag(map, screen_index, fillscr, targetflag, sx, sy+1, down, diagonal);
8489
8490 if((sx>0) && (dir!=right))
8491 fill_flag(map, screen_index, fillscr, targetflag, sx-1, sy, left, diagonal);
8492
8493 if((sx<15) && (dir!=left))
8494 fill_flag(map, screen_index, fillscr, targetflag, sx+1, sy, right, diagonal);
8495
8496 if(diagonal==1)
8497 {
8498 if((sy>0) && (sx>0) && (dir!=r_down))
8499 fill_flag(map, screen_index, fillscr, targetflag, sx-1, sy-1, l_up, diagonal);
8500
8501 if((sy<10) && (sx<15) && (dir!=l_up))
8502 fill_flag(map, screen_index, fillscr, targetflag, sx+1, sy+1, r_down, diagonal);
8503
8504 if((sx>0) && (sy<10) && (dir!=r_up))
8505 fill_flag(map, screen_index, fillscr, targetflag, sx-1, sy+1, l_down, diagonal);
8506
8507 if((sx<15) && (sy>0) && (dir!=l_down))
8508 fill_flag(map, screen_index, fillscr, targetflag, sx+1, sy-1, r_up, diagonal);
8509 }
8510
8511 }
8512
8513 static void fill2(mapscr* fillscr, int32_t targetcombo, int32_t targetcset, int32_t sx, int32_t sy, int32_t dir, int32_t diagonal, bool only_cset)
8514 {
8515 if(!only_cset)
8516 {
8517 if((fillscr->data[((sy<<4)+sx)])==targetcombo)
8518 return;
8519 }
8520
8521 if((fillscr->cset[((sy<<4)+sx)])==targetcset)
8522 return;
8523
8524 int32_t cid = Combo;
8525 int8_t cs = CSet;
8526 if(draw_mode == dm_cpool)
8527 {
8528 combo_pool const& pool = combo_pools[combo_pool_pos];
8529 if(!pool.pick(cid,cs)) return;
8530 }
8531
8532 Map.DoSetComboCommand(Map.getCurrMap(), Map.getCurrScr(), (sy<<4)+sx, only_cset ? -1 : cid, cs);
8533
8534 if((sy>0) && (dir!=down)) // && ((Map.CurrScr()->data[(((sy-1)<<4)+sx)]&0x7FF)!=target))
8535 fill2(fillscr, targetcombo, targetcset, sx, sy-1, up, diagonal, only_cset);
8536
8537 if((sy<10) && (dir!=up)) // && ((Map.CurrScr()->data[(((sy+1)<<4)+sx)]&0x7FF)!=target))
8538 fill2(fillscr, targetcombo, targetcset, sx, sy+1, down, diagonal, only_cset);
8539
8540 if((sx>0) && (dir!=right)) // && ((Map.CurrScr()->data[((sy<<4)+sx-1)]&0x7FF)!=target))
8541 fill2(fillscr, targetcombo, targetcset, sx-1, sy, left, diagonal, only_cset);
8542
8543 if((sx<15) && (dir!=left)) // && ((Map.CurrScr()->data[((sy<<4)+sx+1)]&0x7FF)!=target))
8544 fill2(fillscr, targetcombo, targetcset, sx+1, sy, right, diagonal, only_cset);
8545
8546 if(diagonal==1)
8547 {
8548 if((sy>0) && (sx>0) && (dir!=r_down)) // && ((Map.CurrScr()->data[(((sy-1)<<4)+sx-1)]&0x7FF)!=target))
8549 fill2(fillscr, targetcombo, targetcset, sx-1, sy-1, l_up, diagonal, only_cset);
8550
8551 if((sy<10) && (sx<15) && (dir!=l_up)) // && ((Map.CurrScr()->data[(((sy+1)<<4)+sx+1)]&0x7FF)!=target))
8552 fill2(fillscr, targetcombo, targetcset, sx+1, sy+1, r_down, diagonal, only_cset);
8553
8554 if((sx>0) && (sy<10) && (dir!=r_up)) // && ((Map.CurrScr()->data[(((sy+1)<<4)+sx-1)]&0x7FF)!=target))
8555 fill2(fillscr, targetcombo, targetcset, sx-1, sy+1, l_down, diagonal, only_cset);
8556
8557 if((sx<15) && (sy>0) && (dir!=l_down)) // && ((Map.CurrScr()->data[(((sy-1)<<4)+sx+1)]&0x7FF)!=target))
8558 fill2(fillscr, targetcombo, targetcset, sx+1, sy-1, r_up, diagonal, only_cset);
8559 }
8560 }
8561
8562
8563 /**************************/
8564 /***** Mouse *****/
8565 /**************************/
8566
8567 #define SNAP_NONE 0xFF
8568 #define SNAP_HALF 0xF8
8569 #define SNAP_WHOLE 0xF0
8570 static void doxypos(byte &px2, byte &py2, int32_t color, int32_t mask,
8571 int32_t shiftmask, bool immediately, int32_t cursoroffx,
8572 int32_t cursoroffy, int32_t iconw, int32_t iconh)
8573 {
8574 int32_t tempcb=ComboBrush;
8575 ComboBrush=0;
8576 MouseSprite::set(ZQM_POINT_BOX);
8577
8578 int32_t oldpx=px2, oldpy=py2;
8579 int32_t startxint=mapscreen_x+(showedges?int32_t(16*mapscreensize):0);
8580 int32_t startyint=mapscreen_y+(showedges?int32_t(16*mapscreensize):0);
8581 showxypos_x=px2;
8582 showxypos_y=py2;
8583 showxypos_w=iconw;
8584 showxypos_h=iconh;
8585 showxypos_color=vc(color);
8586 showxypos_icon=!showxypos_dummy;
8587 bool canedit=false;
8588 bool done=false;
8589
8590 clear_tooltip();
8591
8592 while(!done && (!(gui_mouse_b()&2) || immediately))
8593 {
8594 int32_t x=gui_mouse_x();
8595 int32_t y=gui_mouse_y();
8596
8597 if(!gui_mouse_b() || immediately)
8598 {
8599 canedit=true;
8600 }
8601
8602 if(canedit && gui_mouse_b()==1 && isinRect(x,y,startxint,startyint,(startxint+(256*mapscreensize)-1),(startyint+(176*mapscreensize)-1)))
8603 {
8604 set_mouse_range(startxint,startyint,int32_t(startxint+(256*mapscreensize)-1),int32_t(startyint+(176*mapscreensize)-1));
8605
8606 while(gui_mouse_b()==1)
8607 {
8608 x=int32_t((gui_mouse_x()-startxint)/mapscreensize)-cursoroffx;
8609 y=int32_t((gui_mouse_y()-startyint)/mapscreensize)-cursoroffy;
8610 showxypos_cursor_icon=true;
8611 showxypos_cursor_color = showxypos_color;
8612 auto _mask = (key[KEY_LSHIFT] || key[KEY_RSHIFT]) ? shiftmask : mask;
8613 showxypos_cursor_x=x&_mask;
8614 showxypos_cursor_y=y&_mask;
8615 custom_vsync();
8616 refresh(rALL | rNOCURSOR);
8617 int32_t xpos[2], ypos[2];
8618 int32_t x1,y1,x2,y2;
8619
8620 char b1[200] = {0};
8621 char b2[200] = {0};
8622 if(showxypos_dummy)
8623 strcpy(b1, "DUMMY MEASURING");
8624 else sprintf(b1, "%d %d",oldpx,oldpy);
8625 sprintf(b2, "%d %d (%d %d)",x,y,showxypos_cursor_x,showxypos_cursor_y);
8626
8627 int len[2] = {text_length(font,b1),text_length(font,b2)};
8628
8629 if(is_compact)
8630 {
8631 xpos[0] = 4;
8632 ypos[0] = layer_panel.y - 21;
8633 xpos[1] = xpos[0];
8634 ypos[1] = ypos[0]+10;
8635 }
8636 else
8637 {
8638 xpos[0] = 450;
8639 ypos[0] = 405;
8640 xpos[1] = xpos[0];
8641 ypos[1] = ypos[0]+10;
8642 }
8643
8644 x1 = xpos[0];
8645 y1 = ypos[0];
8646 x2 = xpos[0];
8647 y2 = ypos[0];
8648 for(auto q = 0; q < 2; ++q)
8649 {
8650 if(xpos[q] < x1)
8651 x1 = xpos[q];
8652 if(ypos[q] < y1)
8653 y1 = ypos[q];
8654 if(ypos[q] > y2)
8655 y2 = ypos[q];
8656 if(xpos[q] + len[q] > x2)
8657 x2 = xpos[q] + len[q];
8658 }
8659 x1 -= 4;
8660 y1 -= 2;
8661 y2 += text_height(font)+2;
8662
8663 auto minx = zc_min(xpos[0],xpos[1]);
8664 auto miny = zc_min(ypos[0],ypos[1]);
8665 rectfill(screen,x1,y1,x2,y2,vc(0));
8666 textprintf_ex(screen,font,xpos[0],ypos[0],vc(15),vc(0),"%s",b1);
8667 textprintf_ex(screen,font,xpos[1],ypos[1],vc(15),vc(0),"%s",b2);
8668 update_hw_screen(true);
8669 }
8670
8671 if(gui_mouse_b()==0)
8672 {
8673 auto _mask = (key[KEY_LSHIFT] || key[KEY_RSHIFT]) ? shiftmask : mask;
8674 px2=byte(vbound(x,0,255)&_mask);
8675 py2=byte(vbound(y,0,255)&_mask);
8676 }
8677
8678 set_mouse_range(0,0,zq_screen_w-1,zq_screen_h-1);
8679 done=true;
8680 }
8681
8682 if(keypressed())
8683 {
8684 switch(readkey()>>8)
8685 {
8686 case KEY_ESC:
8687 case KEY_ENTER:
8688 goto finished;
8689 }
8690 }
8691
8692 custom_vsync();
8693 refresh(rALL | rNOCURSOR);
8694 }
8695
8696 finished:
8697 MouseSprite::set(ZQM_NORMAL);
8698 refresh(rMAP+rMENU);
8699
8700 while(gui_mouse_b())
8701 {
8702 /* do nothing */
8703 rest(1);
8704 }
8705
8706 showxypos_x=-1000;
8707 showxypos_y=-1000;
8708 showxypos_color=-1000;
8709 showxypos_ffc=-1000;
8710 showxypos_icon=false;
8711 showxypos_cursor_x=-1000;
8712 showxypos_cursor_y=-1000;
8713 showxypos_cursor_icon=false;
8714 showxypos_cursor_color=-1000;
8715 showxypos_dummy=false;
8716
8717 if(px2!=oldpx||py2!=oldpy)
8718 {
8719 saved=false;
8720 }
8721
8722 ComboBrush=tempcb;
8723 }
8724 static void doxypos(byte &px2,byte &py2,int32_t color,int32_t mask,int32_t shiftmask = 0)
8725 {
8726 doxypos(px2,py2,color,mask,shiftmask ? shiftmask : mask,false,0,0,16,16);
8727 }
8728
8729 bool placing_flags = false;
8730 void doflags()
8731 {
8732 placing_flags = true;
8733 int of=Flags;
8734 Flags=cFLAGS;
8735 refresh(rMAP | rNOCURSOR);
8736
8737 bool canedit=false;
8738 bool didShift = false;
8739 int tFlag = Flag;
8740 while(!(gui_mouse_b()&2) && !handle_close_btn_quit())
8741 {
8742 int x=gui_mouse_x();
8743 int y=gui_mouse_y();
8744 double startx=mapscreen_x+(showedges?(16*mapscreensize):0);
8745 double starty=mapscreen_y+(showedges?(16*mapscreensize):0);
8746 int startxint=mapscreen_x+(showedges?int(16*mapscreensize):0);
8747 int startyint=mapscreen_y+(showedges?int(16*mapscreensize):0);
8748 int cx=(x-startxint)/int(16*mapscreensize);
8749 int cy=(y-startyint)/int(16*mapscreensize);
8750 int c=(cy*16)+cx;
8751
8752 if(!gui_mouse_b())
8753 canedit=true;
8754 bool shift = key[KEY_LSHIFT] || key[KEY_RSHIFT];
8755 if(canedit && gui_mouse_b()==1 && isinRect(x,y,startxint,startyint,int(startx+(256*mapscreensize)-1),int(starty+(176*mapscreensize)-1)))
8756 {
8757 mapscr* cur_scr = (CurrentLayer
8758 ? &(TheMaps[(Map.CurrScr()->layermap[CurrentLayer-1]-1)*MAPSCRS
8759 +(Map.CurrScr()->layerscreen[CurrentLayer-1])])
8760 : Map.CurrScr());
8761 if(key[KEY_ALT]||key[KEY_ALTGR])
8762 Flag = cur_scr->sflag[c];
8763 else
8764 {
8765 saved=false;
8766 int tflag = Flag;
8767 if(shift)
8768 Flag = mfNONE;
8769 if(CurrentLayer!=0)
8770 {
8771 // Notify if they are using a flag that doesn't work on this layer.
8772 if(!skipLayerWarning && ((Flag >= mfTRAP_H && Flag < mfPUSHD) || (Flag == mfFAIRY) || (Flag == mfMAGICFAIRY)
8773 || (Flag == mfALLFAIRY) || (Flag == mfRAFT) || (Flag == mfRAFT_BRANCH)
8774 || (Flag == mfDIVE_ITEM) || (Flag == mfARMOS_SECRET) || (Flag == mfNOENEMY)
8775 || (Flag == mfZELDA)))
8776 {
8777 InfoDialog("Notice","You are currently working on layer "
8778 +to_string(CurrentLayer)
8779 +". This combo flag does not function on layers above '0'.").show();
8780 }
8781 if(!skipLayerWarning && CurrentLayer > 2 &&
8782 ((Flag == mfBLOCKHOLE) || (Flag >= mfPUSHD && Flag < mfNOBLOCKS)
8783 || (Flag == mfPUSHUD) || (Flag == mfPUSH4)))
8784 {
8785 InfoDialog("Notice","You are currently working on layer "
8786 +to_string(CurrentLayer)
8787 +". This combo flag does not function on layers above '2'.").show();
8788 }
8789 }
8790 if(CHECK_CTRL_CMD)
8791 {
8792 switch(fill_type)
8793 {
8794 case 0:
8795 flood_flag();
8796 break;
8797
8798 case 1:
8799 case 3:
8800 fill_4_flag();
8801 break;
8802
8803 case 2:
8804 case 4:
8805 fill_8_flag();
8806 break;
8807 }
8808 }
8809 else
8810 {
8811 int map = CurrentLayer ? Map.CurrScr()->layermap[CurrentLayer-1]-1 : Map.getCurrMap();
8812 int scr = CurrentLayer ? Map.CurrScr()->layerscreen[CurrentLayer-1] : Map.getCurrScr();
8813 Map.DoSetFlagCommand(map, scr, c, Flag);
8814 }
8815 if(!(cur_scr->valid&mVALID))
8816 {
8817 Map.CurrScr()->valid|=mVALID;
8818 cur_scr->valid|=mVALID;
8819 Map.setcolor(Color);
8820 }
8821 Flag = tflag;
8822 }
8823 }
8824
8825 if(mouse_z)
8826 {
8827 for(int i=0; i<abs(mouse_z); ++i)
8828 {
8829 if(mouse_z>0)
8830 onIncreaseFlag();
8831 else
8832 onDecreaseFlag();
8833 }
8834
8835 position_mouse_z(0);
8836 }
8837
8838 if(keypressed())
8839 {
8840 int k = readkey();
8841 switch(k>>8)
8842 {
8843 case KEY_ESC:
8844 case KEY_ENTER:
8845 goto finished;
8846 }
8847 object_message(dialogs+1, MSG_XCHAR, k);
8848 Flags=cFLAGS;
8849 }
8850
8851 MouseSprite::set(ZQM_FLAG_0+(shift?0:Flag%16));
8852
8853 refresh(rALL | rCLEAR | rNOCURSOR);
8854 custom_vsync();
8855 }
8856
8857 finished:
8858 Flags=of;
8859 placing_flags = false;
8860 MouseSprite::set(ZQM_NORMAL);
8861 refresh(rMAP+rMENU);
8862
8863 while(gui_mouse_b())
8864 {
8865 /* do nothing */
8866 rest(1);
8867 }
8868 }
8869
8870 // Drag FFCs around
8871 void moveffc(int32_t i, int32_t cx, int32_t cy)
8872 {
8873 int32_t ffx = vbound(Map.CurrScr()->ffcs[i].x.getFloor(),0,240);
8874 int32_t ffy = vbound(Map.CurrScr()->ffcs[i].y.getFloor(),0,160);
8875 int32_t offx = ffx, offy = ffy;
8876 showxypos_ffc = i;
8877 doxypos((byte&)ffx,(byte&)ffy,15,SNAP_HALF,SNAP_NONE,true,cx-ffx,cy-ffy,(Map.CurrScr()->ffTileWidth(i)*16),(Map.CurrScr()->ffTileHeight(i)*16));
8878 if(ffx > 240) ffx = 240;
8879 if(ffy > 160) ffy = 160;
8880 if((ffx != offx) || (ffy != offy))
8881 {
8882 auto set_ffc_data = set_ffc_command::create_data(Map.CurrScr()->ffcs[i]);
8883 set_ffc_data.x = ffx;
8884 set_ffc_data.y = ffy;
8885 Map.DoSetFFCCommand(Map.getCurrMap(), Map.getCurrScr(), i, set_ffc_data);
8886 saved = false;
8887 }
8888 }
8889
8890 void set_brush_width(int32_t width);
8891 void set_brush_height(int32_t height);
8892
8893 int32_t set_brush_width_1()
8894 {
8895 set_brush_width(1);
8896 return D_O_K;
8897 }
8898 int32_t set_brush_width_2()
8899 {
8900 set_brush_width(2);
8901 return D_O_K;
8902 }
8903 int32_t set_brush_width_3()
8904 {
8905 set_brush_width(3);
8906 return D_O_K;
8907 }
8908 int32_t set_brush_width_4()
8909 {
8910 set_brush_width(4);
8911 return D_O_K;
8912 }
8913 int32_t set_brush_width_5()
8914 {
8915 set_brush_width(5);
8916 return D_O_K;
8917 }
8918 int32_t set_brush_width_6()
8919 {
8920 set_brush_width(6);
8921 return D_O_K;
8922 }
8923 int32_t set_brush_width_7()
8924 {
8925 set_brush_width(7);
8926 return D_O_K;
8927 }
8928 int32_t set_brush_width_8()
8929 {
8930 set_brush_width(8);
8931 return D_O_K;
8932 }
8933 int32_t set_brush_width_9()
8934 {
8935 set_brush_width(9);
8936 return D_O_K;
8937 }
8938 int32_t set_brush_width_10()
8939 {
8940 set_brush_width(10);
8941 return D_O_K;
8942 }
8943 int32_t set_brush_width_11()
8944 {
8945 set_brush_width(11);
8946 return D_O_K;
8947 }
8948 int32_t set_brush_width_12()
8949 {
8950 set_brush_width(12);
8951 return D_O_K;
8952 }
8953 int32_t set_brush_width_13()
8954 {
8955 set_brush_width(13);
8956 return D_O_K;
8957 }
8958 int32_t set_brush_width_14()
8959 {
8960 set_brush_width(14);
8961 return D_O_K;
8962 }
8963 int32_t set_brush_width_15()
8964 {
8965 set_brush_width(15);
8966 return D_O_K;
8967 }
8968 int32_t set_brush_width_16()
8969 {
8970 set_brush_width(16);
8971 return D_O_K;
8972 }
8973
8974 int32_t set_brush_height_1()
8975 {
8976 set_brush_height(1);
8977 return D_O_K;
8978 }
8979 int32_t set_brush_height_2()
8980 {
8981 set_brush_height(2);
8982 return D_O_K;
8983 }
8984 int32_t set_brush_height_3()
8985 {
8986 set_brush_height(3);
8987 return D_O_K;
8988 }
8989 int32_t set_brush_height_4()
8990 {
8991 set_brush_height(4);
8992 return D_O_K;
8993 }
8994 int32_t set_brush_height_5()
8995 {
8996 set_brush_height(5);
8997 return D_O_K;
8998 }
8999 int32_t set_brush_height_6()
9000 {
9001 set_brush_height(6);
9002 return D_O_K;
9003 }
9004 int32_t set_brush_height_7()
9005 {
9006 set_brush_height(7);
9007 return D_O_K;
9008 }
9009 int32_t set_brush_height_8()
9010 {
9011 set_brush_height(8);
9012 return D_O_K;
9013 }
9014 int32_t set_brush_height_9()
9015 {
9016 set_brush_height(9);
9017 return D_O_K;
9018 }
9019 int32_t set_brush_height_10()
9020 {
9021 set_brush_height(10);
9022 return D_O_K;
9023 }
9024 int32_t set_brush_height_11()
9025 {
9026 set_brush_height(11);
9027 return D_O_K;
9028 }
9029
9030
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu brush_width_menu
9031 136 {
9032
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "1", set_brush_width_1 },
9033
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "2", set_brush_width_2 },
9034
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "3", set_brush_width_3 },
9035
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "4", set_brush_width_4 },
9036
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "5", set_brush_width_5 },
9037
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "6", set_brush_width_6 },
9038
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "7", set_brush_width_7 },
9039
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "8", set_brush_width_8 },
9040
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "9", set_brush_width_9 },
9041
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "10", set_brush_width_10 },
9042
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "11", set_brush_width_11 },
9043
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "12", set_brush_width_12 },
9044
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "13", set_brush_width_13 },
9045
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "14", set_brush_width_14 },
9046
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "15", set_brush_width_15 },
9047
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "16", set_brush_width_16 },
9048 };
9049
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu brush_height_menu
9050 96 {
9051
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "1", set_brush_height_1 },
9052
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "2", set_brush_height_2 },
9053
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "3", set_brush_height_3 },
9054
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "4", set_brush_height_4 },
9055
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "5", set_brush_height_5 },
9056
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "6", set_brush_height_6 },
9057
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "7", set_brush_height_7 },
9058
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "8", set_brush_height_8 },
9059
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "9", set_brush_height_9 },
9060
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "10", set_brush_height_10 },
9061
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "11", set_brush_height_11 },
9062 };
9063
9064 int toggle_autobrush();
9065 int toggle_combobrush();
9066 int toggle_floatbrush();
9067 enum
9068 {
9069 MENUID_BRUSH_AUTOBRUSH,
9070 MENUID_BRUSH_WIDTH,
9071 MENUID_BRUSH_HEIGHT,
9072 MENUID_BRUSH_COMBOBRUSH,
9073 MENUID_BRUSH_FLOATBRUSH,
9074 };
9075
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu brush_menu
9076 48 {
9077
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "AutoBrush", toggle_autobrush, MENUID_BRUSH_AUTOBRUSH },
9078
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Brush Width ", &brush_width_menu, MENUID_BRUSH_WIDTH },
9079
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Brush Height ", &brush_height_menu, MENUID_BRUSH_HEIGHT },
9080
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "ComboBrush", toggle_combobrush, MENUID_BRUSH_COMBOBRUSH },
9081
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "FloatBrush", toggle_floatbrush, MENUID_BRUSH_FLOATBRUSH },
9082 };
9083 int toggle_autobrush()
9084 {
9085 AutoBrush = AutoBrush ? 0 : 1;
9086 BrushWidth = BrushHeight = 1;
9087 brush_menu.select_uid(MENUID_BRUSH_AUTOBRUSH, AutoBrush);
9088 brush_menu.disable_uid(MENUID_BRUSH_WIDTH, AutoBrush);
9089 brush_menu.disable_uid(MENUID_BRUSH_HEIGHT, AutoBrush);
9090 zc_set_config("zquest","autobrush",AutoBrush);
9091 return D_O_K;
9092 }
9093 int toggle_combobrush()
9094 {
9095 ComboBrush = ComboBrush ? 0 : 1;
9096 brush_menu.select_uid(MENUID_BRUSH_COMBOBRUSH, ComboBrush);
9097 zc_set_config("zquest","combo_brush",ComboBrush);
9098 return D_O_K;
9099 }
9100 int toggle_floatbrush()
9101 {
9102 FloatBrush = FloatBrush ? 0 : 1;
9103 brush_menu.select_uid(MENUID_BRUSH_FLOATBRUSH, FloatBrush);
9104 zc_set_config("zquest","float_brush",FloatBrush);
9105 return D_O_K;
9106 }
9107
9108 int32_t set_flood();
9109 int32_t set_fill_4();
9110 int32_t set_fill_8();
9111 int32_t set_fill2_4();
9112 int32_t set_fill2_8();
9113
9114 void flood()
9115 {
9116 int32_t drawmap, drawscr;
9117
9118 if(CurrentLayer==0)
9119 {
9120 drawmap=Map.getCurrMap();
9121 drawscr=Map.getCurrScr();
9122 }
9123 else
9124 {
9125 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
9126 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
9127 }
9128 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
9129 if(!draw_mapscr) return;
9130
9131 saved=false;
9132
9133 if(!(draw_mapscr->valid&mVALID))
9134 {
9135 Map.CurrScr()->valid|=mVALID;
9136 draw_mapscr->valid|=mVALID;
9137 Map.setcolor(Color);
9138 }
9139
9140 bool include_combos = !(key[KEY_LSHIFT]||key[KEY_RSHIFT]);
9141 Map.StartListCommand();
9142
9143 for(int32_t i=0; i<176; i++)
9144 {
9145 if (draw_mode == dm_auto)
9146 draw_autocombo(i, gui_mouse_b() & 2);
9147 else
9148 Map.DoSetComboCommand(drawmap, drawscr, i, include_combos ? Combo : -1, CSet);
9149 }
9150
9151 Map.FinishListCommand();
9152 refresh(rMAP+rSCRMAP);
9153 }
9154 void flood_flag()
9155 {
9156 int32_t drawmap, drawscr;
9157
9158 if(CurrentLayer==0)
9159 {
9160 drawmap=Map.getCurrMap();
9161 drawscr=Map.getCurrScr();
9162 }
9163 else
9164 {
9165 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
9166 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
9167 }
9168 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
9169 if(!draw_mapscr) return;
9170
9171 saved=false;
9172
9173 if(!(draw_mapscr->valid&mVALID))
9174 {
9175 Map.CurrScr()->valid|=mVALID;
9176 draw_mapscr->valid|=mVALID;
9177 Map.setcolor(Color);
9178 }
9179
9180 Map.StartListCommand();
9181 for(int32_t i=0; i<176; i++)
9182 {
9183 Map.DoSetFlagCommand(drawmap, drawscr, i, Flag);
9184 }
9185 Map.FinishListCommand();
9186
9187 refresh(rMAP+rSCRMAP);
9188 }
9189
9190 void fill_4()
9191 {
9192 int32_t drawmap, drawscr;
9193
9194 if(CurrentLayer==0)
9195 {
9196 drawmap=Map.getCurrMap();
9197 drawscr=Map.getCurrScr();
9198 }
9199 else
9200 {
9201 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
9202 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
9203 }
9204 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
9205 if(!draw_mapscr) return;
9206
9207 int32_t x=gui_mouse_x()-mapscreen_x-(showedges?(16*mapscreensize):0);
9208 int32_t y=gui_mouse_y()-mapscreen_y-(showedges?(16*mapscreensize):0);
9209 int32_t by= (y>>4)/(mapscreensize);
9210 int32_t bx= (x>>4)/(mapscreensize);
9211
9212 if(draw_mode == dm_cpool || draw_mode == dm_auto
9213 || (draw_mapscr->cset[(by<<4)+bx]!=CSet ||
9214 (draw_mapscr->data[(by<<4)+bx]!=Combo &&
9215 !(key[KEY_LSHIFT]||key[KEY_RSHIFT]))))
9216 {
9217 saved=false;
9218
9219 if(!(draw_mapscr->valid&mVALID))
9220 {
9221 Map.CurrScr()->valid|=mVALID;
9222 draw_mapscr->valid|=mVALID;
9223 Map.setcolor(Color);
9224 }
9225
9226 Map.StartListCommand();
9227 if (draw_mode == dm_auto && (combo_autos[combo_auto_pos].getType() == AUTOCOMBO_FENCE ||
9228 combo_autos[combo_auto_pos].getType() == AUTOCOMBO_Z4))
9229 {
9230 draw_autocombo_command((by << 4) + bx);
9231 }
9232 else
9233 {
9234 bool filled_combos[176] = { false };
9235 fill(drawmap, drawscr, draw_mapscr,
9236 (draw_mapscr->data[(by << 4) + bx]),
9237 (draw_mapscr->cset[(by << 4) + bx]), bx, by, 255, 0, (key[KEY_LSHIFT] || key[KEY_RSHIFT]), filled_combos);
9238 }
9239 Map.FinishListCommand();
9240 refresh(rMAP+rSCRMAP);
9241 }
9242 }
9243 void fill_4_flag()
9244 {
9245 int32_t drawmap, drawscr;
9246
9247 if(CurrentLayer==0)
9248 {
9249 drawmap=Map.getCurrMap();
9250 drawscr=Map.getCurrScr();
9251 }
9252 else
9253 {
9254 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
9255 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
9256 }
9257 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
9258 if(!draw_mapscr) return;
9259
9260 int32_t x=gui_mouse_x()-mapscreen_x-(showedges?(16*mapscreensize):0);
9261 int32_t y=gui_mouse_y()-mapscreen_y-(showedges?(16*mapscreensize):0);
9262 int32_t by= (y>>4)/(mapscreensize);
9263 int32_t bx= (x>>4)/(mapscreensize);
9264
9265 if(draw_mapscr->sflag[(by<<4)+bx] != Flag)
9266 {
9267 saved=false;
9268
9269 if(!(draw_mapscr->valid&mVALID))
9270 {
9271 Map.CurrScr()->valid|=mVALID;
9272 draw_mapscr->valid|=mVALID;
9273 Map.setcolor(Color);
9274 }
9275
9276 Map.StartListCommand();
9277 fill_flag(drawmap, drawscr, draw_mapscr,
9278 (draw_mapscr->sflag[(by<<4)+bx]),
9279 bx, by, 255, 0);
9280 Map.FinishListCommand();
9281 refresh(rMAP+rSCRMAP);
9282 }
9283 }
9284 void fill_8()
9285 {
9286 int32_t drawmap, drawscr;
9287
9288 if(CurrentLayer==0)
9289 {
9290 drawmap=Map.getCurrMap();
9291 drawscr=Map.getCurrScr();
9292 }
9293 else
9294 {
9295 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
9296 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
9297 }
9298 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
9299 if(!draw_mapscr) return;
9300
9301 int32_t x=gui_mouse_x()-mapscreen_x-(showedges?(16*mapscreensize):0);
9302 int32_t y=gui_mouse_y()-mapscreen_y-(showedges?(16*mapscreensize):0);
9303 int32_t by= (y>>4)/(mapscreensize);
9304 int32_t bx= (x>>4)/(mapscreensize);
9305
9306 if(draw_mode == dm_cpool || draw_mode == dm_auto
9307 || (draw_mapscr->cset[(by<<4)+bx]!=CSet ||
9308 (draw_mapscr->data[(by<<4)+bx]!=Combo &&
9309 !(key[KEY_LSHIFT]||key[KEY_RSHIFT]))))
9310 {
9311 saved=false;
9312
9313 if(!(draw_mapscr->valid&mVALID))
9314 {
9315 Map.CurrScr()->valid|=mVALID;
9316 draw_mapscr->valid|=mVALID;
9317 Map.setcolor(Color);
9318 }
9319
9320 Map.StartListCommand();
9321 bool filled_combos[176] = { false };
9322 fill(drawmap, drawscr, draw_mapscr,
9323 (draw_mapscr->data[(by<<4)+bx]),
9324 (draw_mapscr->cset[(by<<4)+bx]), bx, by, 255, 1, (key[KEY_LSHIFT]||key[KEY_RSHIFT]), filled_combos);
9325 Map.FinishListCommand();
9326 refresh(rMAP+rSCRMAP);
9327 }
9328 }
9329 void fill_8_flag()
9330 {
9331 int32_t drawmap, drawscr;
9332
9333 if(CurrentLayer==0)
9334 {
9335 drawmap=Map.getCurrMap();
9336 drawscr=Map.getCurrScr();
9337 }
9338 else
9339 {
9340 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
9341 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
9342 }
9343 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
9344 if(!draw_mapscr) return;
9345
9346 int32_t x=gui_mouse_x()-mapscreen_x-(showedges?(16*mapscreensize):0);
9347 int32_t y=gui_mouse_y()-mapscreen_y-(showedges?(16*mapscreensize):0);
9348 int32_t by= (y>>4)/(mapscreensize);
9349 int32_t bx= (x>>4)/(mapscreensize);
9350
9351 if(draw_mapscr->sflag[(by<<4)+bx]!=Flag)
9352 {
9353 saved=false;
9354
9355 if(!(draw_mapscr->valid&mVALID))
9356 {
9357 Map.CurrScr()->valid|=mVALID;
9358 draw_mapscr->valid|=mVALID;
9359 Map.setcolor(Color);
9360 }
9361
9362 Map.StartListCommand();
9363 fill_flag(drawmap, drawscr, draw_mapscr,
9364 (draw_mapscr->sflag[(by<<4)+bx]),
9365 bx, by, 255, 1);
9366 Map.FinishListCommand();
9367 refresh(rMAP+rSCRMAP);
9368 }
9369 }
9370
9371 void fill2_4()
9372 {
9373 int32_t drawmap, drawscr;
9374
9375 if(CurrentLayer==0)
9376 {
9377 drawmap=Map.getCurrMap();
9378 drawscr=Map.getCurrScr();
9379 }
9380 else
9381 {
9382 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
9383 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
9384 }
9385 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
9386 if(!draw_mapscr) return;
9387
9388 int32_t x=gui_mouse_x()-mapscreen_x-(showedges?(16*mapscreensize):0);
9389 int32_t y=gui_mouse_y()-mapscreen_y-(showedges?(16*mapscreensize):0);;
9390 int32_t by= (((y&0xF0))>>4)/(mapscreensize);
9391 int32_t bx= (x>>4)/(mapscreensize);
9392
9393 saved=false;
9394
9395 if(!(draw_mapscr->valid&mVALID))
9396 {
9397 Map.CurrScr()->valid|=mVALID;
9398 draw_mapscr->valid|=mVALID;
9399 Map.setcolor(Color);
9400 }
9401
9402 Map.StartListCommand();
9403 fill2(draw_mapscr, Combo, CSet, bx, by, 255, 0, (key[KEY_LSHIFT]||key[KEY_RSHIFT]));
9404 Map.FinishListCommand();
9405 refresh(rMAP+rSCRMAP);
9406 }
9407
9408 void fill2_8()
9409 {
9410 int32_t drawmap, drawscr;
9411
9412 if(CurrentLayer==0)
9413 {
9414 drawmap=Map.getCurrMap();
9415 drawscr=Map.getCurrScr();
9416 }
9417 else
9418 {
9419 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
9420 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
9421 }
9422 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
9423 if(!draw_mapscr) return;
9424
9425 int32_t x=gui_mouse_x()-mapscreen_x-(showedges?(16*mapscreensize):0);
9426 int32_t y=gui_mouse_y()-mapscreen_y-(showedges?(16*mapscreensize):0);;
9427 int32_t by= (((y&0xF0))>>4)/(mapscreensize);
9428 int32_t bx= (x>>4)/(mapscreensize);
9429
9430 saved=false;
9431
9432 if(!(draw_mapscr->valid&mVALID))
9433 {
9434 Map.CurrScr()->valid|=mVALID;
9435 draw_mapscr->valid|=mVALID;
9436 Map.setcolor(Color);
9437 }
9438
9439 Map.StartListCommand();
9440 fill2(draw_mapscr, Combo, CSet, bx, by, 255, 1, (key[KEY_LSHIFT]||key[KEY_RSHIFT]));
9441 Map.FinishListCommand();
9442 refresh(rMAP+rSCRMAP);
9443 }
9444
9445 enum
9446 {
9447
9448 };
9449
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu fill_menu
9450 48 {
9451
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Flood", set_flood, 0 },
9452
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Fill (4-way)", set_fill_4, 1 },
9453
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Fill (8-way)", set_fill_8, 2 },
9454
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Fill2 (4-way)", set_fill2_4, 3 },
9455
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Fill2 (8-way)", set_fill2_8, 4 },
9456 };
9457 void set_filltype(int ty)
9458 {
9459 fill_type = ty;
9460 fill_menu.select_only_uid(ty);
9461 }
9462
9463 int32_t set_flood()
9464 {
9465 set_filltype(0);
9466 return D_O_K;
9467 }
9468
9469 int32_t set_fill_4()
9470 {
9471 set_filltype(1);
9472 return D_O_K;
9473 }
9474
9475 int32_t set_fill_8()
9476 {
9477 set_filltype(2);
9478 return D_O_K;
9479 }
9480
9481 int32_t set_fill2_4()
9482 {
9483 set_filltype(3);
9484 return D_O_K;
9485 }
9486
9487 int32_t set_fill2_8()
9488 {
9489 set_filltype(4);
9490 return D_O_K;
9491 }
9492
9493 int32_t draw_block_1_2()
9494 {
9495 draw_block(mousecomboposition,1,2);
9496 return D_O_K;
9497 }
9498
9499 int32_t draw_block_2_1()
9500 {
9501 draw_block(mousecomboposition,2,1);
9502 return D_O_K;
9503 }
9504
9505 int32_t draw_block_2_2()
9506 {
9507 draw_block(mousecomboposition,2,2);
9508 return D_O_K;
9509 }
9510
9511 int32_t draw_block_2_3()
9512 {
9513 draw_block(mousecomboposition,2,3);
9514 return D_O_K;
9515 }
9516
9517 int32_t draw_block_3_2()
9518 {
9519 draw_block(mousecomboposition,3,2);
9520 return D_O_K;
9521 }
9522
9523 int32_t draw_block_3_3()
9524 {
9525 draw_block(mousecomboposition,3,3);
9526 return D_O_K;
9527 }
9528
9529 int32_t draw_block_4_2()
9530 {
9531 draw_block(mousecomboposition,4,2);
9532 return D_O_K;
9533 }
9534
9535 int32_t draw_block_4_4()
9536 {
9537 draw_block(mousecomboposition,4,4);
9538 return D_O_K;
9539 }
9540
9541
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu draw_block_menu
9542 72 {
9543
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "1x2", draw_block_1_2 },
9544
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "2x1", draw_block_2_1 },
9545
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "2x2", draw_block_2_2 },
9546
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "2x3", draw_block_2_3 },
9547
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "3x2", draw_block_3_2 },
9548
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "3x3", draw_block_3_3 },
9549
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "4x2", draw_block_4_2 },
9550
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "4x4", draw_block_4_4 },
9551 };
9552
9553
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu paste_screen_menu
9554 40 {
9555
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Paste", onPaste },
9556
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Paste All", onPasteAll },
9557
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Paste to All", onPasteToAll },
9558
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Paste All to All", onPasteAllToAll },
9559 };
9560
9561 int32_t scrollto_cmb(int32_t cid)
9562 {
9563 auto& sqr = combolist[current_combolist];
9564 int32_t res = vbound(cid-(sqr.w*sqr.h/2),0,MAXCOMBOS-(sqr.w*sqr.h));
9565 res -= res%sqr.w;
9566 return res;
9567 }
9568 int32_t scrollto_alias(int32_t alid)
9569 {
9570 auto& sqr = comboaliaslist[current_comboalist];
9571 int32_t res = vbound(alid-(sqr.w*sqr.h/2),0,MAXCOMBOALIASES-(sqr.w*sqr.h));
9572 res -= res%sqr.w;
9573 return res;
9574 }
9575
9576 int32_t scrollto_cpool(int32_t cpid)
9577 {
9578 auto& sqr = comboaliaslist[current_cpoollist];
9579 int32_t res = vbound(cpid-(sqr.w*sqr.h/2),0,MAXCOMBOPOOLS-(sqr.w*sqr.h));
9580 res -= res%sqr.w;
9581 return res;
9582 }
9583
9584 int32_t scrollto_cauto(int32_t caid)
9585 {
9586 auto& sqr = comboaliaslist[current_cautolist];
9587 int32_t res = vbound(caid - (sqr.w * sqr.h / 2), 0, MAXCOMBOPOOLS - (sqr.w * sqr.h));
9588 res -= res % sqr.w;
9589 return res;
9590 }
9591
9592 void add_favorite_combo_block(int32_t favind, int32_t cid, bool force)
9593 {
9594 int32_t w = vbound(BrushWidth, 1, 4);
9595 int32_t h = vbound(BrushHeight, 1, 7);
9596 for (int32_t xi = 0; xi < w; ++xi)
9597 {
9598 for (int32_t yi = 0; yi < h; ++yi)
9599 {
9600 int32_t cx = cid % 4;
9601 int32_t cy = cid / 4;
9602 int32_t cc = (cy + yi) * 4 + cx + xi;
9603 int32_t fx = favind % FAVORITECOMBO_PER_ROW;
9604 int32_t fy = favind / FAVORITECOMBO_PER_ROW;
9605 int32_t fc = (fy + yi) * FAVORITECOMBO_PER_ROW + fx + xi + FAVORITECOMBO_PER_PAGE * FavoriteComboPage;
9606
9607 if (cx + xi < 4 && cc < MAXCOMBOS && fx + xi < FAVORITECOMBO_PER_ROW && fy + yi < FAVORITECOMBO_PER_COLUMN)
9608 {
9609 if (favorite_combos[fc] < 0 || force)
9610 {
9611 favorite_combo_modes[fc] = dm_normal;
9612 favorite_combos[fc] = cc;
9613 }
9614 }
9615 }
9616 }
9617 }
9618
9619 void onRCSelectCombo(int32_t c)
9620 {
9621 int32_t drawmap, drawscr;
9622
9623 if(CurrentLayer==0)
9624 {
9625 drawmap=Map.getCurrMap();
9626 drawscr=Map.getCurrScr();
9627 }
9628 else
9629 {
9630 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
9631 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
9632 }
9633 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
9634 if(!draw_mapscr) return;
9635
9636 Combo=draw_mapscr->data[c];
9637 if(AutoBrush)
9638 BrushWidth = BrushHeight = 1;
9639 }
9640
9641 void onRCScrollToombo(int32_t c)
9642 {
9643 int32_t drawmap, drawscr;
9644
9645 if(CurrentLayer==0)
9646 {
9647 drawmap=Map.getCurrMap();
9648 drawscr=Map.getCurrScr();
9649 }
9650 else
9651 {
9652 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
9653 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
9654 }
9655 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
9656 if(!draw_mapscr) return;
9657
9658 auto& sqr = combolist[current_combolist];
9659 First[current_combolist]=scrollto_cmb(draw_mapscr->data[c]);
9660 }
9661
9662 enum
9663 {
9664 MENUID_RCSCREEN_PASTE,
9665 MENUID_RCSCREEN_ADVPASTE,
9666 MENUID_RCSCREEN_SPECPASTE,
9667 };
9668
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 static NewMenu rc_menu_screen
9669 40 {
9670
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Copy Screen", onCopy },
9671
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "Paste Screen", &paste_screen_menu, MENUID_RCSCREEN_PASTE },
9672
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "...Advanced Paste", &paste_menu, MENUID_RCSCREEN_ADVPASTE },
9673
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 { "...Special Paste", &paste_item_menu, MENUID_RCSCREEN_SPECPASTE },
9674 };
9675
9676 void follow_twarp(int warpindex)
9677 {
9678 if(warpindex >= 4)
9679 {
9680 InfoDialog("Random Tile Warp",
9681 "This is a random tile warp combo, so it chooses"
9682 " randomly between the screen's four Tile Warps.").show();
9683 warpindex=zc_oldrand()&3;
9684 }
9685
9686 int32_t tm = Map.getCurrMap();
9687 int32_t ts = Map.getCurrScr();
9688 int32_t wt = Map.CurrScr()->tilewarptype[warpindex];
9689
9690 if(wt==wtCAVE || wt==wtNOWARP)
9691 {
9692 char buf[56];
9693 InfoDialog(warptype_string[wt],fmt::format("This screen's Tile Warp {} is set to {}, so it doesn't lead to another screen.",'A'+warpindex,warptype_string[wt]));
9694 return;
9695 }
9696
9697 Map.dowarp(0,warpindex);
9698
9699 if(ts!=Map.getCurrScr() || tm!=Map.getCurrMap())
9700 {
9701 FlashWarpSquare = (TheMaps[tm*MAPSCRS+ts].warpreturnc>>(warpindex*2))&3;
9702 FlashWarpClk = 32;
9703 }
9704 }
9705 void edit_twarp(int warpindex)
9706 {
9707 if(warpindex>=4)
9708 {
9709 InfoDialog("Random Tile Warp",
9710 "This is a random tile warp combo, so it chooses"
9711 " randomly between the screen's four Tile Warps.").show();
9712 warpindex=zc_oldrand()&3;
9713 }
9714
9715 if(warpindex > -1 && warpindex < 4)
9716 onTileWarpIndex(warpindex);
9717 }
9718
9719 int toggle_linked_scrolling()
9720 {
9721 LinkedScroll = LinkedScroll ? 0 : 1;
9722 zc_set_config("zquest","linked_comboscroll",LinkedScroll);
9723 return D_O_K;
9724 }
9725 void on_scroll_cpane()
9726 {
9727 switch (draw_mode)
9728 {
9729 case dm_alias:
9730 combo_alistpos[current_comboalist] = scrollto_alias(combo_apos);
9731 break;
9732 case dm_cpool:
9733 combo_pool_listpos[current_cpoollist] = scrollto_cpool(combo_pool_pos);
9734 break;
9735 case dm_auto:
9736 combo_auto_listpos[current_cautolist] = scrollto_cauto(combo_auto_pos);
9737 break;
9738 default:
9739 First[current_combolist] = scrollto_cmb(Combo);
9740 break;
9741 }
9742 }
9743 void on_edit_cpane()
9744 {
9745 switch (draw_mode)
9746 {
9747 case dm_alias:
9748 onEditComboAlias();
9749 break;
9750 case dm_cpool:
9751 onEditComboPool();
9752 break;
9753 case dm_auto:
9754 onEditAutoCombo();
9755 break;
9756 default:
9757 reset_combo_animations();
9758 reset_combo_animations2();
9759 edit_combo(Combo, true, CSet);
9760 setup_combo_animations();
9761 setup_combo_animations2();
9762 break;
9763 }
9764 }
9765 void on_cpane_page()
9766 {
9767 switch(draw_mode)
9768 {
9769 case dm_normal:
9770 combo_screen(Combo>>8,Combo);
9771 break;
9772 case dm_alias:
9773 call_alias_pages(combo_apos);
9774 break;
9775 case dm_auto:
9776 call_autoc_pages(combo_auto_pos);
9777 break;
9778 case dm_cpool:
9779 call_cpool_pages(combo_pool_pos);
9780 break;
9781 }
9782 }
9783 void open_cpane_tilepage()
9784 {
9785 onGotoTiles(combobuf[Combo].o_tile);
9786 }
9787 static int _clicked_fav = 0;
9788 void fav_rc_remove()
9789 {
9790 favorite_combo_modes[_clicked_fav] = dm_normal;
9791 favorite_combos[_clicked_fav] = -1;
9792 saved = false;
9793 }
9794 void popup_favorites_rc(int f, int x, int y)
9795 {
9796 _clicked_fav = f;
9797 string type;
9798 switch (draw_mode)
9799 {
9800 case dm_alias:
9801 type = "Alias";
9802 break;
9803 case dm_cpool:
9804 type = "Pool";
9805 break;
9806 case dm_auto:
9807 type = "Autocombo";
9808 break;
9809 case dm_normal:
9810 type = "Combo";
9811 break;
9812 default: return;
9813 }
9814 NewMenu rcmenu
9815 {
9816 { fmt::format("Scroll to {}", type), on_scroll_cpane },
9817 { fmt::format("Edit {}", type), on_edit_cpane },
9818 { fmt::format("Open {} Page", type), on_cpane_page },
9819 { fmt::format("Remove Fav {}", type), fav_rc_remove },
9820 };
9821 switch (draw_mode)
9822 {
9823 case dm_normal:
9824 rcmenu.add({
9825 {},
9826 { "Open Tile Page", open_cpane_tilepage },
9827 });
9828 break;
9829 }
9830 rcmenu.pop(x, y);
9831 }
9832 void popup_cpane_rc(int x, int y)
9833 {
9834 string type;
9835 switch (draw_mode)
9836 {
9837 case dm_alias:
9838 type = "Alias";
9839 break;
9840 case dm_cpool:
9841 type = "Pool";
9842 break;
9843 case dm_auto:
9844 type = "Autocombo";
9845 break;
9846 case dm_normal:
9847 type = "Combo";
9848 break;
9849 default: return;
9850 }
9851 NewMenu rcmenu;
9852 switch(draw_mode)
9853 {
9854 case dm_normal:
9855 rcmenu.add({
9856 { fmt::format("Edit {}", type), on_edit_cpane },
9857 { fmt::format("Open {} Page", type), on_cpane_page },
9858 { "Open Tile Page", open_cpane_tilepage },
9859 { "Combo Locations", onComboLocationReport },
9860 {},
9861 { "Scroll to Page...", onGotoPage },
9862 { "Linked Scrolling", toggle_linked_scrolling, nullopt, LinkedScroll ? MFL_SEL : 0 },
9863 });
9864 break;
9865 case dm_alias:
9866 case dm_cpool:
9867 case dm_auto:
9868 rcmenu.add({
9869 { fmt::format("Edit {}", type), on_edit_cpane },
9870 { fmt::format("Open {} Page", type), on_cpane_page },
9871 {},
9872 { "Scroll to Page...", onGotoPage },
9873 { "Linked Scrolling", toggle_linked_scrolling, nullopt, LinkedScroll ? MFL_SEL : 0 },
9874 });
9875 break;
9876 }
9877 rcmenu.pop(x, y);
9878 }
9879
9880 void set_brush_width(int32_t width)
9881 {
9882 BrushWidth = width;
9883 for(int q = 0; q < brush_width_menu.size(); ++q)
9884 brush_width_menu.at(q)->select(q==BrushWidth-1);
9885 refresh(rALL);
9886 }
9887
9888 void set_brush_height(int32_t height)
9889 {
9890 BrushHeight = height;
9891 for(int q = 0; q < brush_height_menu.size(); ++q)
9892 brush_height_menu.at(q)->select(q==BrushHeight-1);
9893 refresh(rALL);
9894 }
9895
9896 void restore_mouse()
9897 {
9898 ComboBrushPause=1;
9899 MouseSprite::set(ZQM_NORMAL);
9900 }
9901
9902 static int32_t comboa_cnt=0;
9903 static int32_t combop_cnt=0;
9904 static int32_t layer_cnt=0;
9905
9906 static char paste_ffc_menu_text[21];
9907 static char paste_ffc_menu_text2[21];
9908 static char follow_warp_menu_text[21];
9909 static char follow_warp_menu_text2[21];
9910
9911 static int fake_mouse_b(){return 0;}
9912 static int (*mouseb_proc)();
9913 static bool killed_mouse = false;
9914 void zq_killmouse()
9915 {
9916 if(killed_mouse) return;
9917 mouseb_proc = gui_mouse_b;
9918 gui_mouse_b = fake_mouse_b;
9919 killed_mouse = true;
9920 }
9921 void zq_restoremouse()
9922 {
9923 if(!killed_mouse) return;
9924 gui_mouse_b = mouseb_proc;
9925 killed_mouse = false;
9926 }
9927
9928
9929 void domouse()
9930 {
9931 static int mouse_down = 0;
9932 static int32_t scrolldelay = 0;
9933 auto mousexy = zc_get_mouse();
9934 auto x = mousexy.first;
9935 auto y = mousexy.second;
9936 double startx=mapscreen_x+(showedges?(16*mapscreensize):0);
9937 double starty=mapscreen_y+(showedges?(16*mapscreensize):0);
9938 int32_t startxint=mapscreen_x+(showedges?int32_t(16*mapscreensize):0);
9939 int32_t startyint=mapscreen_y+(showedges?int32_t(16*mapscreensize):0);
9940 int32_t cx=(x-startxint)/int32_t(16*mapscreensize);
9941 int32_t cy=(y-startyint)/int32_t(16*mapscreensize);
9942 int32_t c=(cy*16)+cx;
9943
9944 if (draw_mode == dm_auto)
9945 {
9946 if (c != mousecomboposition)
9947 combobrushoverride = get_autocombo_floating_cid(c, false);
9948 }
9949 else
9950 combobrushoverride = -1;
9951
9952 mousecomboposition=c;
9953 update_combobrush();
9954 // put_combo(brushbmp,0,0,Combo,CSet,0,0);
9955
9956 ++scrolldelay;
9957
9958 bool x_on_list = false;
9959 for(auto q = 0; q < num_combo_cols; ++q)
9960 {
9961 if((x>=combolist[q].x) && (x<combolist[q].x+(combolist[q].xscale*combolist[q].w)))
9962 {
9963 x_on_list = true;
9964 break;
9965 }
9966 }
9967 if(MouseScroll && x_on_list && (key[KEY_LSHIFT] || key[KEY_RSHIFT] || (scrolldelay&3)==0))
9968 {
9969 int32_t test_list=0;
9970
9971 for(test_list=0; test_list<3; ++test_list)
9972 {
9973 if((x>=combolist[test_list].x) && (x<combolist[test_list].x+(combolist[test_list].xscale*combolist[test_list].w)))
9974 {
9975 break;
9976 }
9977 }
9978
9979 if(test_list<3)
9980 {
9981 if(y>=combolist[test_list].y-mouse_scroll_h && y<=combolist[test_list].y && First[test_list])
9982 {
9983 if((CHECK_CTRL_CMD)&&(key[KEY_ALT] || key[KEY_ALTGR]))
9984 {
9985 First[test_list]=0;
9986 }
9987 else if(CHECK_CTRL_CMD)
9988 {
9989 First[test_list]-=zc_min(First[test_list],256);
9990 }
9991 else if(key[KEY_ALT] || key[KEY_ALTGR])
9992 {
9993 First[test_list]-=zc_min(First[test_list],(combolist[test_list].w*combolist[test_list].h));
9994 }
9995 else
9996 {
9997 First[test_list]-=zc_min(First[test_list],combolist[test_list].w);
9998 }
9999 }
10000
10001 if(y>=combolist[test_list].y+(combolist[test_list].h*combolist[test_list].yscale)-1 && y<combolist[test_list].y+(combolist[test_list].h*combolist[test_list].yscale)+mouse_scroll_h-1 && First[test_list]<(MAXCOMBOS-(combolist[test_list].w*combolist[test_list].h)))
10002 {
10003 int32_t offset = combolist[test_list].w*combolist[test_list].h;
10004
10005 if((CHECK_CTRL_CMD)&&(key[KEY_ALT] || key[KEY_ALTGR]))
10006 {
10007 First[test_list]=MAXCOMBOS-offset;
10008 }
10009 else if(CHECK_CTRL_CMD)
10010 {
10011 First[test_list] = zc_min(MAXCOMBOS-offset, First[test_list]+256);
10012 }
10013 else if(key[KEY_ALT] || key[KEY_ALTGR])
10014 {
10015 First[test_list] = zc_min(MAXCOMBOS-offset, First[test_list]+ offset);
10016 }
10017 else
10018 {
10019 First[test_list] = zc_min(MAXCOMBOS - offset, First[test_list] + combolist[test_list].w);
10020 }
10021 }
10022 }
10023 }
10024
10025 //-------------
10026 //tooltip stuff
10027 //-------------
10028 if(isinRect(x,y,startxint,startyint,startxint+(256*mapscreensize)-1,startyint+(176*mapscreensize)-1))
10029 {
10030 static int mapscr_tooltip_id = ttip_register_id();
10031 bool did_ffttip = false;
10032 for(int32_t i=MAXFFCS-1; i>=0; i--)
10033 if(Map.CurrScr()->ffcs[i].data !=0 && (CurrentLayer<2 || (Map.CurrScr()->ffcs[i].flags&ffOVERLAY)))
10034 {
10035 int32_t ffx = Map.CurrScr()->ffcs[i].x.getFloor();
10036 int32_t ffy = Map.CurrScr()->ffcs[i].y.getFloor();
10037 int32_t ffw = Map.CurrScr()->ffTileWidth(i)*16;
10038 int32_t ffh = Map.CurrScr()->ffTileHeight(i)*16;
10039 int32_t cx2 = (x-startxint)/mapscreensize;
10040 int32_t cy2 = (y-startyint)/mapscreensize;
10041
10042 if(cx2 >= ffx && cx2 < ffx+ffw && cy2 >= ffy && cy2 < ffy+ffh)
10043 {
10044 // FFC tooltip
10045 if(tooltip_current_ffc != i)
10046 {
10047 clear_tooltip();
10048 }
10049
10050 tooltip_current_ffc = i;
10051 char msg[1024] = {0};
10052 auto& ff = Map.CurrScr()->ffcs[i];
10053 sprintf(msg,"FFC: %d Combo: %d\nCSet: %d Type: %s\nScript: %s",
10054 i+1, ff.data,ff.data,
10055 combo_class_buf[combobuf[ff.data].type].name,
10056 (ff.script<=0 ? "(None)" : ffcmap[ff.script-1].scriptname.substr(0,400).c_str()));
10057 ttip_install(mapscr_tooltip_id, msg, startxint+(ffx*mapscreensize), startyint+(ffy*mapscreensize), ffw*mapscreensize, ffh*mapscreensize, x, y);
10058 did_ffttip = true;
10059 break;
10060 }
10061 }
10062 if(!did_ffttip)
10063 {
10064 int32_t drawmap;
10065 int32_t drawscr;
10066
10067 if(CurrentLayer==0)
10068 {
10069 drawmap=Map.getCurrMap();
10070 drawscr=Map.getCurrScr();
10071 }
10072 else
10073 {
10074 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
10075 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
10076 }
10077
10078 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
10079 if(unsigned(c) < 176 && draw_mapscr && !gui_mouse_b())
10080 {
10081 int cid = draw_mapscr->data[c];
10082 newcombo const& cmb = combobuf[cid];
10083 std::ostringstream oss;
10084 int cs = draw_mapscr->cset[c];
10085 int sflag = draw_mapscr->sflag[c];
10086 oss << "Pos: " << c
10087 << "\nCombo: " << cid
10088 << "\nCSet: " << cs;
10089 if(sflag || cmb.flag)
10090 oss << "\nFlags: " << sflag << ", " << (int)cmb.flag;
10091 if(cmb.type)
10092 oss << "\nCombo type: " << combo_class_buf[cmb.type].name;
10093 if(cmb.label[0])
10094 oss << "\nLabel: " << cmb.label;
10095 ttip_install(mapscr_tooltip_id, oss.str().c_str(), startxint+(cx*16*mapscreensize), startyint+(cy*16*mapscreensize), 16*mapscreensize, 16*mapscreensize, x, y);
10096 }
10097 }
10098 }
10099
10100 {
10101 size_and_pos* squares[4] = {&itemsqr_pos,&stairsqr_pos,&warparrival_pos,&flagsqr_pos};
10102 for(int32_t j=0; j<4; j++)
10103 {
10104 auto& square = *squares[j];
10105 if(square.rect(x,y))
10106 {
10107 char msg[160];
10108 sprintf(msg,
10109 j==0 ? "Item Location" :
10110 j==1 ? "Stairs Secret\nTriggered when a Trigger Push Block is pushed." :
10111 j==2 ? "Arrival Square\nPlayer's location when they begin/resume the game." :
10112 "Combo Flags");
10113 update_tooltip(x,y,square,msg);
10114 }
10115 }
10116
10117 // Warp Returns
10118 for(int32_t j=0; j<4; j++)
10119 {
10120 size_and_pos& wret = warpret_pos[j];
10121 if(wret.rect(x,y))
10122 {
10123 char msg[160];
10124 sprintf(msg,"Warp Return Square %c\nPlayer's destination after warping to this screen.",(char)('A'+j));
10125 update_tooltip(x,y,wret,msg);
10126 }
10127 }
10128
10129 // Enemies
10130 if(enemy_prev_pos.rect(x,y))
10131 {
10132 char msg[160];
10133 sprintf(msg,"Enemies that appear on this screen.");
10134 update_tooltip(x,y,enemy_prev_pos,msg);
10135 }
10136
10137 int32_t cmd = commands_list.rectind(x,y);
10138 if(cmd > -1)
10139 {
10140 update_tooltip(x,y,commands_list.subsquare(cmd),
10141 fmt::format("Fav Command {}: {}\n{}", cmd,
10142 get_hotkey_name(favorite_commands[cmd]),
10143 get_hotkey_helptext(favorite_commands[cmd])).c_str());
10144 }
10145 }
10146
10147 if(draw_mode==dm_alias)
10148 {
10149 for(int32_t j=0; j<num_combo_cols; ++j)
10150 {
10151 auto& sqr = comboaliaslist[j];
10152 auto ind = sqr.rectind(x,y);
10153 if(ind > -1)
10154 {
10155 auto c2=ind+combo_alistpos[j];
10156 char msg[80];
10157 sprintf(msg, "Combo alias %d", c2);
10158 update_tooltip(x,y,sqr.subsquare(ind), msg);
10159 }
10160 }
10161 }
10162 else if(draw_mode==dm_cpool)
10163 {
10164 for(int32_t j=0; j<num_combo_cols; ++j)
10165 {
10166 auto& sqr = comboaliaslist[j];
10167 auto ind = sqr.rectind(x,y);
10168 if(ind > -1)
10169 {
10170 auto c2=ind+combo_pool_listpos[j];
10171 char msg[80];
10172 sprintf(msg, "Combo Pool %d", c2);
10173 update_tooltip(x,y,sqr.subsquare(ind), msg);
10174 }
10175 }
10176 if(cpool_prev_visible && combopool_prevbtn.rect(x,y))
10177 {
10178 if(do_layer_button_reset(combopool_prevbtn.x,combopool_prevbtn.y,
10179 combopool_prevbtn.w,combopool_prevbtn.h,
10180 weighted_cpool ? "Weighted" : "Unweighted",0,true))
10181 {
10182 weighted_cpool = !weighted_cpool;
10183 }
10184 }
10185 }
10186 else if (draw_mode == dm_auto)
10187 {
10188 for (int32_t j = 0; j < num_combo_cols; ++j)
10189 {
10190 auto& sqr = comboaliaslist[j];
10191 auto ind = sqr.rectind(x, y);
10192 if (ind > -1)
10193 {
10194 auto c2 = ind + combo_auto_listpos[j];
10195 char msg[80];
10196 sprintf(msg, "Auto Combo %d", c2);
10197 update_tooltip(x, y, sqr.subsquare(ind), msg);
10198 }
10199 }
10200 }
10201 else
10202 {
10203 if(combo_preview.rect(x,y))
10204 {
10205 auto str = "Combo Colors:\n"+get_combo_colornames(Combo,CSet);
10206 update_tooltip(x,y,combo_preview,str.c_str());
10207 }
10208 else if(comboprev_buf[0] && combo_preview_text1.rect(x,y))
10209 {
10210 update_tooltip(x,y,combo_preview_text1,comboprev_buf);
10211 }
10212 else if(comboprev_buf2[0] && combo_preview_text2.rect(x,y))
10213 {
10214 update_tooltip(x,y,combo_preview_text2,comboprev_buf2);
10215 }
10216 else for(int32_t j=0; j<num_combo_cols; ++j)
10217 {
10218 auto& sqr = combolist[j];
10219 auto ind = sqr.rectind(x,y);
10220 if(ind > -1)
10221 {
10222 int32_t c2=ind+First[j];
10223 std::ostringstream oss;
10224 newcombo const& cmb = combobuf[c2];
10225 oss << "Combo " << c2 << ": " << combo_class_buf[cmb.type].name;
10226 if(cmb.flag != 0)
10227 oss << "\nInherent flag: " << ZI.getMapFlagName(cmb.flag);
10228 if(!cmb.label.empty())
10229 oss << "\nLabel: " << cmb.label;
10230
10231 update_tooltip(x,y,sqr.subsquare(ind), oss.str().c_str());
10232 }
10233 }
10234 }
10235
10236 if (favorites_list.rect(x, y))
10237 {
10238 int32_t f = favorites_list.rectind(x, y);
10239 int32_t row = f / favorites_list.w;
10240 int32_t col = f % favorites_list.w;
10241 f = (row * FAVORITECOMBO_PER_ROW) + col;
10242
10243 auto& sqr = favorites_list.subsquare(col, row);
10244
10245 char buf[180];
10246 if (favorite_combos[f] == -1)
10247 sprintf(buf, "Fav Combo %d\nEmpty", f);
10248 else
10249 {
10250 switch (favorite_combo_modes[f])
10251 {
10252 case dm_alias:
10253 sprintf(buf, "Fav Combo %d\nAlias %d", f, favorite_combos[f]);
10254 break;
10255 case dm_cpool:
10256 sprintf(buf, "Fav Combo %d\nPool %d", f, favorite_combos[f]);
10257 break;
10258 case dm_auto:
10259 sprintf(buf, "Fav Combo %d\nAutocombo %d", f, favorite_combos[f]);
10260 break;
10261 default:
10262 sprintf(buf, "Fav Combo %d\nCombo %d", f, favorite_combos[f]);
10263 }
10264 }
10265 update_tooltip(x, y, sqr, buf);
10266 }
10267
10268 size_and_pos const& real_mini = zoomed_minimap ? real_minimap_zoomed : real_minimap;
10269 auto ind = real_mini.rectind(x,y);
10270 if(ind > -1)
10271 {
10272 char buf[80];
10273 sprintf(buf,"0x%02X (%d)", ind, ind);
10274 ttip_install(minimap_tooltip_id, buf, real_mini.subsquare(ind), real_mini.x+real_mini.tw(), real_mini.y-16);
10275 ttip_set_highlight_thickness(minimap_tooltip_id, zoomed_minimap ? 2 : 1);
10276 // Make sure always above the other tooltip items to the right of the map (even in big map mode).
10277 ttip_set_z_index(minimap_tooltip_id, 100);
10278 ttip_clear_timer();
10279 }
10280 else
10281 {
10282 ttip_uninstall(minimap_tooltip_id);
10283 }
10284
10285 // Mouse clicking stuff
10286 int real_mb = gui_mouse_b();
10287 int mb = real_mb & ~mouse_down; //Only handle clicks that have not been handled already
10288 auto mz = mouse_z;
10289 bool lclick = mb&1;
10290 bool rclick = mb&2;
10291
10292 if (mb && hotkeys_is_active())
10293 {
10294 hotkeys_toggle_display(false);
10295 while (gui_mouse_b())
10296 {
10297 custom_vsync();
10298 }
10299 return;
10300 }
10301
10302 FONT* tfont = font;
10303 if(zoomed_minimap)
10304 {
10305 if((lclick||rclick) && !minimap_zoomed.rect(x,y))
10306 {
10307 // 'Clicked off'
10308 mmap_set_zoom(false);
10309 goto domouse_doneclick;
10310 }
10311 }
10312
10313 if(real_mb==0)
10314 {
10315 mouse_down = 0;
10316 canfill=true;
10317 }
10318 else if(lclick || rclick)
10319 {
10320 //on the minimap
10321 if(real_mini.rect(x,y))
10322 {
10323 if(lclick)
10324 select_scr();
10325 else if(rclick && !(mouse_down&2))
10326 {
10327 mmap_set_zoom(!zoomed_minimap);
10328 }
10329 goto domouse_doneclick;
10330 }
10331
10332 if(zoomed_minimap && minimap_zoomed.rect(x,y))
10333 goto domouse_doneclick; //Eat clicks
10334
10335 //on the map tabs
10336 font = get_custom_font(CFONT_GUI);
10337 for(int32_t btn=0; btn<mappage_count; ++btn)
10338 {
10339 char tbuf[15];
10340 sprintf(tbuf, "%d:%02X", map_page[btn].map+1, map_page[btn].screen);
10341 auto& sqr = map_page_bar[btn];
10342 if(sqr.rect(x,y))
10343 {
10344 if(do_layer_button_reset(sqr.x,sqr.y,sqr.w,sqr.h,tbuf,(btn==current_mappage?D_SELECTED:0)))
10345 {
10346 draw_layer_button(screen, sqr.x,sqr.y,sqr.w,sqr.h,tbuf,D_SELECTED);
10347 map_page[current_mappage].map=Map.getCurrMap();
10348 map_page[current_mappage].screen=Map.getCurrScr();
10349 current_mappage=btn;
10350 Map.setCurrMap(map_page[current_mappage].map);
10351 Map.setCurrScr(map_page[current_mappage].screen);
10352 rebuild_trans_table(); //Woo
10353 }
10354 goto domouse_doneclick;
10355 }
10356 }
10357
10358 if(compactbtn.rect(x,y))
10359 {
10360 if(do_text_button(compactbtn.x, compactbtn.y, compactbtn.w, compactbtn.h, is_compact ? "< Expand" : "> Compact"));
10361 toggle_is_compact();
10362 goto domouse_doneclick;
10363 }
10364
10365 font = get_zc_font(font_lfont_l);
10366 if(combo_merge_btn.rect(x,y))
10367 {
10368 bool merged = is_compact ? compact_merged_combopane : large_merged_combopane;
10369 if(do_text_button(combo_merge_btn.x,combo_merge_btn.y,combo_merge_btn.w,combo_merge_btn.h,merged ? "<|>" : ">|<"))
10370 {
10371 toggle_merged_mode();
10372 }
10373 goto domouse_doneclick;
10374 }
10375
10376 if(favorites_zoombtn.rect(x,y))
10377 {
10378 bool zoomed = is_compact ? compact_zoomed_fav : large_zoomed_fav;
10379 if(do_text_button(favorites_zoombtn.x,favorites_zoombtn.y,favorites_zoombtn.w,favorites_zoombtn.h,zoomed ? "-" : "+"))
10380 {
10381 toggle_favzoom_mode();
10382 }
10383 goto domouse_doneclick;
10384 }
10385 else if(favorites_x.rect(x,y))
10386 {
10387 if(do_text_button(favorites_x.x,favorites_x.y,favorites_x.w,favorites_x.h,"X"))
10388 {
10389 AlertDialog("Clear Favorite Combos",
10390 "Are you sure you want to clear all favorite combos?",
10391 [&](bool ret,bool)
10392 {
10393 if(ret)
10394 {
10395 for(auto q = 0; q < MAXFAVORITECOMBOS; ++q)
10396 {
10397 favorite_combos[q] = -1;
10398 favorite_combo_modes[q] = dm_normal;
10399 }
10400 saved = false;
10401 refresh(rFAVORITES);
10402 }
10403 }).show();
10404 }
10405 goto domouse_doneclick;
10406 }
10407 else if(favorites_infobtn.rect(x,y))
10408 {
10409 if(do_text_button(favorites_infobtn.x,favorites_infobtn.y,favorites_infobtn.w,favorites_infobtn.h,"?"))
10410 {
10411 InfoDialog("Favorite Combos",
10412 "On LClick (empty): Sets clicked favorite to the current combo."
10413 "\nOn LClick: Sets current combo to clicked favorite."
10414 "\nShift+LClick: Sets clicked favorite to current combo."
10415 "\nCtrl+LClick: Clears clicked favorite."
10416 "\nAlt+LClick: Scrolls to clicked favorite."
10417 "\nRClick: Opens context menu."
10418 "\n\nClick the Page buttons (<-/->) to cycle between pages (RClick to jump to a page)"
10419 "\nClick the Zoom button (+/-) to toggle zoom level."
10420 "\nClick the X button to clear all favorite combos.").show();
10421 }
10422 goto domouse_doneclick;
10423 }
10424 else if(favorites_pgleft.rect(x,y))
10425 {
10426 if (do_text_button(favorites_pgleft.x, favorites_pgleft.y, favorites_pgleft.w, favorites_pgleft.h, is_compact ? "<" : "<-"))
10427 {
10428 if (rclick)
10429 {
10430 if(auto val = popup_num_menu(x, y, 1, 9, FavoriteComboPage, [](int p){return fmt::format("Page {}",p);}))
10431 FavoriteComboPage = vbound(*val-1, 0, 8);
10432 }
10433 else
10434 FavoriteComboPage = FavoriteComboPage == 0 ? 8 : --FavoriteComboPage;
10435 reload_zq_gui();
10436 }
10437 goto domouse_doneclick;
10438 }
10439 else if(favorites_pgright.rect(x,y))
10440 {
10441 if (do_text_button(favorites_pgright.x, favorites_pgright.y, favorites_pgright.w, favorites_pgright.h, is_compact ? ">" : "->"))
10442 {
10443 if (rclick)
10444 {
10445 if(auto val = popup_num_menu(x, y, 1, 9, FavoriteComboPage, [](int p){return fmt::format("Page {}",p);}))
10446 FavoriteComboPage = vbound(*val-1, 0, 8);
10447 }
10448 else
10449 FavoriteComboPage = FavoriteComboPage == 8 ? 0 : ++FavoriteComboPage;
10450 reload_zq_gui();
10451 }
10452 goto domouse_doneclick;
10453 }
10454
10455 if(commands_zoombtn.rect(x,y))
10456 {
10457 bool zoomed = is_compact ? compact_zoomed_cmd : large_zoomed_cmd;
10458 if(do_text_button(commands_zoombtn.x,commands_zoombtn.y,commands_zoombtn.w,commands_zoombtn.h,zoomed ? "-" : "+"))
10459 {
10460 toggle_cmdzoom_mode();
10461 }
10462 goto domouse_doneclick;
10463 }
10464 else if(commands_x.rect(x,y))
10465 {
10466 if(do_text_button(commands_x.x,commands_x.y,commands_x.w,commands_x.h,"X"))
10467 {
10468 AlertDialog("Clear Favorite Commands",
10469 "Are you sure you want to clear all favorite commands?",
10470 [&](bool ret,bool)
10471 {
10472 if(ret)
10473 {
10474 char buf[20];
10475 for(auto q = 0; q < MAXFAVORITECOMMANDS; ++q)
10476 {
10477 write_fav_command(q,0);
10478 }
10479 refresh(rFAVORITES);
10480 }
10481 }).show();
10482 }
10483 goto domouse_doneclick;
10484 }
10485 else if(commands_infobtn.rect(x,y))
10486 {
10487 if(do_text_button(commands_infobtn.x,commands_infobtn.y,commands_infobtn.w,commands_infobtn.h,"?"))
10488 {
10489 InfoDialog("Favorite Commands",
10490 "On LClick (empty): Choose a favorite command"
10491 "\nOn LClick: Runs the favorite command"
10492 "\nShift+Click: Choose a favorite command"
10493 "\nRClick: Choose a favorite command"
10494 "\nCtrl+Click: Clears clicked command"
10495 "\nAlt+Click: Shows info on the favorite command"
10496 "\n\nClick the Zoom button (+/-) to toggle zoom level"
10497 "\nClick the X button to clear all favorite commands").show();
10498 }
10499 goto domouse_doneclick;
10500 }
10501 font=tfont;
10502
10503 // On the layer panel
10504 font = get_custom_font(CFONT_GUI);
10505 for(int32_t i=0; i<=6; ++i)
10506 {
10507 int32_t spacing_offs = is_compact ? 2 : 10;
10508 int32_t rx = (i * (layerpanel_buttonwidth+spacing_offs+layerpanel_checkbox_wid)) + layer_panel.x+(is_compact?2:6);
10509 int32_t ry = layer_panel.y;
10510
10511 if((i==0 || Map.CurrScr()->layermap[i-1]) && isinRect(x,y,rx,ry,rx+layerpanel_buttonwidth-1,ry+layerpanel_buttonheight-1))
10512 {
10513 char tbuf[15];
10514
10515 if(i!=0 && Map.CurrScr()->layermap[i-1])
10516 {
10517 if(is_compact)
10518 {
10519 sprintf(tbuf, "%s%d %d:%02X",
10520 (i==2 && Map.CurrScr()->flags7&fLAYER2BG) || (i==3 && Map.CurrScr()->flags7&fLAYER3BG) ? "-":"",
10521 i, Map.CurrScr()->layermap[i-1], Map.CurrScr()->layerscreen[i-1]);
10522 }
10523 else
10524 {
10525 sprintf(tbuf, "%s%d (%d:%02X)",
10526 (i==2 && Map.CurrScr()->flags7&fLAYER2BG) || (i==3 && Map.CurrScr()->flags7&fLAYER3BG) ? "-":"",
10527 i, Map.CurrScr()->layermap[i-1], Map.CurrScr()->layerscreen[i-1]);
10528 }
10529 }
10530 else
10531 {
10532 sprintf(tbuf, "%d", i);
10533 }
10534
10535 if(do_text_button(rx, ry, layerpanel_buttonwidth, layerpanel_buttonheight, tbuf))
10536 {
10537 CurrentLayer = i;
10538 goto domouse_doneclick;
10539 }
10540 }
10541
10542 auto cbyofs = (layerpanel_buttonheight-layerpanel_checkbox_hei)/2;
10543 if(isinRect(x,y,rx+layerpanel_buttonwidth+1,ry+cbyofs,rx+layerpanel_buttonwidth+1+layerpanel_checkbox_wid-1,ry+2+layerpanel_checkbox_hei-1))
10544 {
10545 do_checkbox(menu1,rx+layerpanel_buttonwidth+1,ry+cbyofs,layerpanel_checkbox_wid,layerpanel_checkbox_hei,LayerMaskInt[i]);
10546 goto domouse_doneclick;
10547 }
10548 }
10549 font=tfont;
10550
10551 //Uses lclick/rclick separately
10552
10553 //on the map screen
10554 if(isinRect(x,y,startxint,startyint,startxint+(256*mapscreensize)-1,startyint+(176*mapscreensize)-1))
10555 {
10556 if (draw_mode == dm_auto)
10557 {
10558 if (CHECK_CTRL_CMD)
10559 {
10560 if (canfill)
10561 {
10562 switch (fill_type)
10563 {
10564 case 0:
10565 flood();
10566 break;
10567
10568 case 1:
10569 fill_4();
10570 break;
10571
10572 case 2:
10573 fill_8();
10574 break;
10575
10576 case 3:
10577 fill2_4();
10578 break;
10579
10580 case 4:
10581 fill2_8();
10582 break;
10583 }
10584
10585 canfill = false;
10586 }
10587 }
10588 else
10589 draw(key[KEY_LSHIFT] || key[KEY_RSHIFT]);
10590 }
10591 else if(lclick)
10592 {
10593 int32_t cx2 = (x-startxint)/mapscreensize;
10594 int32_t cy2 = (y-startyint)/mapscreensize;
10595
10596 // Move items
10597 if(Map.CurrScr()->hasitem)
10598 {
10599 int32_t ix = Map.CurrScr()->itemx;
10600 int32_t iy = Map.CurrScr()->itemy;
10601
10602 if(cx2 >= ix && cx2 < ix+16 && cy2 >= iy && cy2 < iy+16)
10603 doxypos(Map.CurrScr()->itemx,Map.CurrScr()->itemy,11,SNAP_HALF,SNAP_NONE,true,0,0,16,16);
10604 }
10605
10606 // Move FFCs
10607 for(int32_t i=MAXFFCS-1; i>=0; i--)
10608 if(Map.CurrScr()->ffcs[i].data !=0 && (CurrentLayer<2 || (Map.CurrScr()->ffcs[i].flags&ffOVERLAY)))
10609 {
10610 int32_t ffx = Map.CurrScr()->ffcs[i].x.getFloor();
10611 int32_t ffy = Map.CurrScr()->ffcs[i].y.getFloor();
10612
10613 if(cx2 >= ffx && cx2 < ffx+(Map.CurrScr()->ffTileWidth(i)*16) && cy2 >= ffy && cy2 < ffy+(Map.CurrScr()->ffTileHeight(i)*16))
10614 {
10615 moveffc(i,cx2,cy2);
10616 break;
10617 }
10618 }
10619
10620 if(key[KEY_ALT]||key[KEY_ALTGR])
10621 {
10622 int32_t drawmap, drawscr;
10623 if(CurrentLayer==0)
10624 {
10625 drawmap=Map.getCurrMap();
10626 drawscr=Map.getCurrScr();
10627 }
10628 else
10629 {
10630 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
10631 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
10632 }
10633 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
10634 if(!draw_mapscr) return;
10635 Combo=draw_mapscr->data[c];
10636 if(AutoBrush)
10637 BrushWidth = BrushHeight = 1;
10638 if(key[KEY_LSHIFT]||key[KEY_RSHIFT])
10639 CSet=draw_mapscr->cset[c];
10640 if(CHECK_CTRL_CMD)
10641 First[current_combolist]=scrollto_cmb(draw_mapscr->data[c]);
10642 }
10643 else if(CHECK_CTRL_CMD)
10644 {
10645 if(canfill)
10646 {
10647 switch(fill_type)
10648 {
10649 case 0:
10650 flood();
10651 break;
10652
10653 case 1:
10654 fill_4();
10655 break;
10656
10657 case 2:
10658 fill_8();
10659 break;
10660
10661 case 3:
10662 fill2_4();
10663 break;
10664
10665 case 4:
10666 fill2_8();
10667 break;
10668 }
10669
10670 canfill=false;
10671 }
10672 }
10673 else draw(key[KEY_LSHIFT] || key[KEY_RSHIFT]);
10674 }
10675 else if(rclick)
10676 {
10677 ComboBrushPause=1;
10678 refresh(rMAP);
10679 restore_mouse();
10680 ComboBrushPause=0;
10681
10682 bool clickedffc = false;
10683 uint32_t earliestfreeffc = MAXFFCS;
10684
10685 // FFC right-click menu
10686 // This loop also serves to find the free ffc with the smallest slot number.
10687 for(int32_t i=MAXFFCS-1; i>=0; i--)
10688 {
10689 auto data = Map.CurrScr()->ffcs[i].data;
10690 if(data==0)
10691 {
10692 if(i < earliestfreeffc)
10693 earliestfreeffc = i;
10694 continue;
10695 }
10696
10697 if(clickedffc || !(Map.CurrScr()->valid&mVALID))
10698 continue;
10699
10700 if(data!=0 && (CurrentLayer<2 || (Map.CurrScr()->ffcs[i].flags&ffOVERLAY)))
10701 {
10702 int32_t ffx = Map.CurrScr()->ffcs[i].x.getFloor();
10703 int32_t ffy = Map.CurrScr()->ffcs[i].y.getFloor();
10704 int32_t cx2 = (x-startxint)/mapscreensize;
10705 int32_t cy2 = (y-startyint)/mapscreensize;
10706
10707 if(cx2 >= ffx && cx2 < ffx+(Map.CurrScr()->ffTileWidth(i)*16) && cy2 >= ffy && cy2 < ffy+(Map.CurrScr()->ffTileHeight(i)*16))
10708 {
10709 NewMenu rcmenu
10710 {
10711 { "Copy FFC", [&](){Map.CopyFFC(i);} },
10712 { "Paste FFC data", [&]()
10713 {
10714 bool didconfirm = false;
10715 AlertDialog("Confirm Paste",
10716 "Really replace the FFC with the data of the copied FFC?",
10717 [&](bool ret,bool)
10718 {
10719 if(ret)
10720 didconfirm = true;
10721 }).show();
10722 if(didconfirm)
10723 {
10724 auto set_ffc_data = Map.getCopyFFCData();
10725 set_ffc_data.x = Map.CurrScr()->ffcs[i].x;
10726 set_ffc_data.y = Map.CurrScr()->ffcs[i].y;
10727 Map.DoSetFFCCommand(Map.getCurrMap(), Map.getCurrScr(), i, set_ffc_data);
10728 }
10729 }, nullopt, Map.getCopyFFC() < 0 },
10730 { "Edit FFC", [&](){call_ffc_dialog(i);} },
10731 { "Clear FFC", [&]()
10732 {
10733 bool didconfirm = false;
10734 AlertDialog("Confirm Clear",
10735 "Really clear this Freeform Combo?",
10736 [&](bool ret,bool)
10737 {
10738 if(ret)
10739 didconfirm = true;
10740 }).show();
10741 if(didconfirm)
10742 {
10743 Map.DoSetFFCCommand(Map.getCurrMap(), Map.getCurrScr(), i, {
10744 .x = 0,
10745 .y = 0,
10746 .vx = 0,
10747 .vy = 0,
10748 .ax = 0,
10749 .ay = 0,
10750 .data = 0,
10751 .cset = 0,
10752 .delay = 0,
10753 .link = 0,
10754 .script = 0,
10755 .tw = 1,
10756 .th = 1,
10757 .ew = 16,
10758 .eh = 16,
10759 .flags = 0,
10760 .inita = 10000,
10761 .initd = 0,
10762 });
10763 saved = false;
10764 }
10765 } },
10766 { "Snap to Grid", [&]()
10767 {
10768 int oldffx = Map.CurrScr()->ffcs[i].x.getInt();
10769 int oldffy = Map.CurrScr()->ffcs[i].y.getInt();
10770 int pos = COMBOPOS(oldffx,oldffy);
10771 int newffy = COMBOY(pos);
10772 int newffx = COMBOX(pos);
10773
10774 auto set_ffc_data = set_ffc_command::create_data(Map.CurrScr()->ffcs[i]);
10775 set_ffc_data.x = newffx;
10776 set_ffc_data.y = newffy;
10777 Map.DoSetFFCCommand(Map.getCurrMap(), Map.getCurrScr(), i, set_ffc_data);
10778
10779 saved = false;
10780 } },
10781 };
10782 rcmenu.pop(x, y);
10783 clickedffc = true;
10784 break;
10785 }
10786 }
10787
10788 }
10789
10790 // Combo right-click menu
10791 if(!clickedffc)
10792 {
10793 int warpindex = Map.warpindex(Map.CurrScr()->data[c]);
10794 string txt_twarp_follow, txt_twarp_edit, txt_ffc_edit, txt_ffc_paste;
10795 bool show_ffcs = earliestfreeffc < MAXFFCS;
10796 bool dis_paste_ffc = Map.getCopyFFC() < 0;
10797 bool show_warps = warpindex > -1;
10798 bool show_warpback = Map.has_warpback();
10799 // FFC-specific options
10800 if(earliestfreeffc < MAXFFCS)
10801 {
10802 txt_ffc_edit = fmt::format("Edit New FFC {}",earliestfreeffc+1);
10803 if(Map.getCopyFFC()>-1)
10804 txt_ffc_paste = fmt::format("Paste FFC as FFC {}",earliestfreeffc+1);
10805 else
10806 txt_ffc_paste = "Paste FFC";
10807 }
10808
10809 if(warpindex > -1)
10810 {
10811 char letter = warpindex==4 ? 'R' : 'A'+warpindex;
10812 txt_twarp_follow = fmt::format("Follow Tile Warp {}",letter);
10813 txt_twarp_edit = fmt::format("Edit Tile Warp {}",letter);
10814 }
10815
10816 int32_t drawmap, drawscr;
10817 if(CurrentLayer==0)
10818 {
10819 drawmap=Map.getCurrMap();
10820 drawscr=Map.getCurrScr();
10821 }
10822 else
10823 {
10824 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
10825 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
10826 }
10827 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
10828 NewMenu draw_rc_menu
10829 {
10830 { "Select Combo", [&]()
10831 {
10832 Combo = draw_mapscr->data[c];
10833 if(AutoBrush)
10834 BrushWidth = BrushHeight = 1;
10835 }, nullopt, !draw_mapscr },
10836 { "Scroll to Combo", [&]()
10837 {
10838 First[current_combolist] = scrollto_cmb(draw_mapscr->data[c]);
10839 }, nullopt, !draw_mapscr },
10840 { "Edit Combo", [&]()
10841 {
10842 edit_combo(draw_mapscr->data[c],true,draw_mapscr->cset[c]);
10843 }, nullopt, !draw_mapscr },
10844 {},
10845 { "Replace All", [&](){replace(c);} },
10846 { "Draw Block", &draw_block_menu },
10847 { "Brush Settings ", &brush_menu },
10848 { "Set Fill Type ", &fill_menu },
10849 };
10850 if(show_warps || show_warpback)
10851 {
10852 draw_rc_menu.add_sep();
10853 if(show_warpback)
10854 draw_rc_menu.add({ "Warp Back", [&](){Map.warpback();} });
10855 if(show_warps)
10856 {
10857 draw_rc_menu.add({ txt_twarp_follow, [&](){follow_twarp(warpindex);} });
10858 draw_rc_menu.add({ txt_twarp_edit, [&](){edit_twarp(warpindex);} });
10859 }
10860 }
10861 if(show_ffcs)
10862 {
10863 draw_rc_menu.add_sep();
10864 draw_rc_menu.add({ txt_ffc_edit, [&]()
10865 {
10866 ffdata tempdat;
10867 tempdat.x = (((x-startxint)/mapscreensize)&(~0x0007))*10000;
10868 tempdat.y = (((y-startyint)/mapscreensize)&(~0x0007))*10000;
10869 tempdat.data = Combo;
10870 tempdat.cset = CSet;
10871 call_ffc_dialog(earliestfreeffc, tempdat);
10872 } });
10873 draw_rc_menu.add({ txt_ffc_paste, [&]()
10874 {
10875 auto set_ffc_data = Map.getCopyFFCData();
10876 set_ffc_data.x = (((x-startxint)/mapscreensize)&(~0x0007));
10877 set_ffc_data.y = (((y-startyint)/mapscreensize)&(~0x0007));
10878 Map.DoSetFFCCommand(Map.getCurrMap(), Map.getCurrScr(), earliestfreeffc, set_ffc_data);
10879 }, nullopt, dis_paste_ffc });
10880 }
10881 draw_rc_menu.add_sep();
10882 draw_rc_menu.add({ "Screen", &rc_menu_screen });
10883 draw_rc_menu.pop(x,y);
10884 }
10885 }
10886 goto domouse_doneclick;
10887 }
10888
10889 //on the drawing mode button
10890 font = get_custom_font(CFONT_GUI);
10891 if(drawmode_btn.rect(x,y))
10892 {
10893 if(lclick)
10894 {
10895 if(do_text_button(drawmode_btn.x,drawmode_btn.y,drawmode_btn.w,drawmode_btn.h,dm_names[draw_mode]))
10896 onDrawingMode();
10897 }
10898 else if(rclick)
10899 drawing_mode_menu.pop(x,y);
10900 goto domouse_doneclick;
10901 }
10902 font=tfont;
10903
10904 //Squares
10905 {
10906 if(squarepanel_swap_btn.rect(x,y))
10907 {
10908 toggle_compact_sqr_mode();
10909 goto domouse_doneclick;
10910 }
10911 if(squarepanel_up_btn.rect(x,y))
10912 {
10913 cycle_compact_sqr(false);
10914 goto domouse_doneclick;
10915 }
10916 if(squarepanel_down_btn.rect(x,y))
10917 {
10918 cycle_compact_sqr(true);
10919 goto domouse_doneclick;
10920 }
10921
10922 bool do_dummyxy = false;
10923 bool dummymode = key[KEY_LSHIFT] || key[KEY_RSHIFT];
10924
10925 if(itemsqr_pos.rect(x,y))
10926 {
10927 if(dummymode) do_dummyxy = true;
10928 else
10929 {
10930 onItem();
10931
10932 if(!rclick && Map.CurrScr()->hasitem)
10933 doxypos(Map.CurrScr()->itemx,Map.CurrScr()->itemy,11,SNAP_HALF,SNAP_NONE);
10934 goto domouse_doneclick;
10935 }
10936 }
10937
10938 if(stairsqr_pos.rect(x,y))
10939 {
10940 if(dummymode) do_dummyxy = true;
10941 else
10942 {
10943 doxypos(Map.CurrScr()->stairx,Map.CurrScr()->stairy,14,SNAP_WHOLE);
10944 goto domouse_doneclick;
10945 }
10946 }
10947
10948 if(warparrival_pos.rect(x,y))
10949 {
10950 if(dummymode) do_dummyxy = true;
10951 else
10952 {
10953 if(get_qr(qr_NOARRIVALPOINT))
10954 {
10955 info_dsa("Arrival Square",
10956 "The arrival square cannot be used unless the QR 'Use Warp Return "
10957 "Points Only' under 'Quest->Options->Combos' is disabled."
10958 "\nGenerally, this square only exists for compatibility purposes, and is not used"
10959 " in creating new quests.",
10960 "dsa_warparrival");
10961 }
10962 else doxypos(Map.CurrScr()->warparrivalx,Map.CurrScr()->warparrivaly,10,SNAP_HALF,SNAP_NONE);
10963 goto domouse_doneclick;
10964 }
10965 }
10966
10967 if(flagsqr_pos.rect(x,y))
10968 {
10969 if(dummymode) do_dummyxy = true;
10970 else
10971 {
10972 onFlags();
10973 goto domouse_doneclick;
10974 }
10975 }
10976
10977 for(auto q = 0; q < 4; ++q)
10978 {
10979 if(warpret_pos[q].rect(x,y))
10980 {
10981 if(dummymode) do_dummyxy = true;
10982 else
10983 {
10984 doxypos(Map.CurrScr()->warpreturnx[q],Map.CurrScr()->warpreturny[q],9,SNAP_HALF,SNAP_NONE);
10985 goto domouse_doneclick;
10986 }
10987 }
10988 }
10989
10990 if(enemy_prev_pos.rect(x,y))
10991 {
10992 if(dummymode) do_dummyxy = true;
10993 else
10994 {
10995 onEnemies();
10996 goto domouse_doneclick;
10997 }
10998 }
10999
11000 if(do_dummyxy)
11001 {
11002 byte x = 0, y = 0;
11003 showxypos_dummy = true;
11004 doxypos(x,y,13,SNAP_HALF,SNAP_NONE);
11005 goto domouse_doneclick;
11006 }
11007 }
11008
11009 if(draw_mode==dm_alias)
11010 {
11011 for(int32_t j=0; j<num_combo_cols; ++j)
11012 {
11013 if(combolistscrollers[j].rectind(x,y)==0 && !mouse_down)
11014 {
11015 scrollup(j);
11016 goto domouse_doneclick;
11017 }
11018 else if(combolistscrollers[j].rectind(x,y)==1 && !mouse_down)
11019 {
11020 scrolldown(j);
11021 goto domouse_doneclick;
11022 }
11023 else if(comboaliaslist[j].rect(x,y))
11024 {
11025 select_comboa(j);
11026
11027 if(rclick && comboaliaslist[j].rect(gui_mouse_x(),gui_mouse_y()))
11028 popup_cpane_rc(x, y);
11029 goto domouse_doneclick;
11030 }
11031 }
11032 }
11033 else if(draw_mode==dm_cpool)
11034 {
11035 for(int32_t j=0; j<num_combo_cols; ++j)
11036 {
11037 if(combolistscrollers[j].rectind(x,y)==0 && !mouse_down)
11038 {
11039 scrollup(j);
11040 goto domouse_doneclick;
11041 }
11042 else if(combolistscrollers[j].rectind(x,y)==1 && !mouse_down)
11043 {
11044 scrolldown(j);
11045 goto domouse_doneclick;
11046 }
11047 else if(comboaliaslist[j].rect(x,y))
11048 {
11049 select_combop(j);
11050
11051 if(rclick && comboaliaslist[j].rect(gui_mouse_x(),gui_mouse_y()))
11052 popup_cpane_rc(x, y);
11053 goto domouse_doneclick;
11054 }
11055 }
11056 }
11057 else if (draw_mode == dm_auto)
11058 {
11059 for (int32_t j = 0; j < num_combo_cols; ++j)
11060 {
11061 if (combolistscrollers[j].rectind(x, y) == 0 && !mouse_down)
11062 {
11063 scrollup(j);
11064 goto domouse_doneclick;
11065 }
11066 else if (combolistscrollers[j].rectind(x, y) == 1 && !mouse_down)
11067 {
11068 scrolldown(j);
11069 goto domouse_doneclick;
11070 }
11071 else if (comboaliaslist[j].rect(x, y))
11072 {
11073 select_autocombo(j);
11074
11075 if(rclick && comboaliaslist[j].rect(gui_mouse_x(),gui_mouse_y()))
11076 popup_cpane_rc(x, y);
11077 goto domouse_doneclick;
11078 }
11079 }
11080 }
11081 else
11082 {
11083 for(int32_t j=0; j<num_combo_cols; ++j)
11084 {
11085 if(combolistscrollers[j].rectind(x,y)==0 && !mouse_down)
11086 {
11087 scrollup(j);
11088 goto domouse_doneclick;
11089 }
11090 else if(combolistscrollers[j].rectind(x,y)==1 && !mouse_down)
11091 {
11092 scrolldown(j);
11093 goto domouse_doneclick;
11094 }
11095 else if(combolist[j].rect(x,y))
11096 {
11097 select_combo(j);
11098
11099 if(rclick && combolist[j].rect(gui_mouse_x(),gui_mouse_y()))
11100 popup_cpane_rc(x, y);
11101 goto domouse_doneclick;
11102 }
11103 }
11104 }
11105
11106 //on the favorites list
11107 if(favorites_list.rect(x,y))
11108 {
11109 if(lclick)
11110 {
11111 int32_t f=favorites_list.rectind(x,y);
11112 int32_t row=f/favorites_list.w;
11113 int32_t col=f%favorites_list.w;
11114 f = (row*FAVORITECOMBO_PER_ROW)+col;
11115 int32_t fp = f + FAVORITECOMBO_PER_PAGE * FavoriteComboPage;
11116
11117 bool dmcond = favorite_combos[fp] < 0;
11118 if((key[KEY_LSHIFT] || key[KEY_RSHIFT] || dmcond) && !(CHECK_CTRL_CMD))
11119 {
11120 int32_t tempcb=ComboBrush;
11121 ComboBrush=0;
11122
11123 while(gui_mouse_b())
11124 {
11125 x=gui_mouse_x();
11126 y=gui_mouse_y();
11127
11128 switch(draw_mode)
11129 {
11130 case dm_alias:
11131 if (favorite_combos[fp] != combo_apos || favorite_combo_modes[fp] != dm_alias)
11132 {
11133 favorite_combo_modes[fp] = dm_alias;
11134 favorite_combos[fp] = combo_apos;
11135 saved = false;
11136 }
11137 break;
11138 case dm_cpool:
11139 if (favorite_combos[fp] != combo_pool_pos || favorite_combo_modes[fp] != dm_cpool)
11140 {
11141 favorite_combo_modes[fp] = dm_cpool;
11142 favorite_combos[fp] = combo_pool_pos;
11143 saved = false;
11144 }
11145 break;
11146 case dm_auto:
11147 if (favorite_combos[fp] != combo_auto_pos || favorite_combo_modes[fp] != dm_auto)
11148 {
11149 favorite_combo_modes[fp] = dm_auto;
11150 favorite_combos[fp] = combo_auto_pos;
11151 saved = false;
11152 }
11153 break;
11154 default:
11155 if (favorite_combos[fp] != Combo || favorite_combo_modes[fp] != dm_normal)
11156 {
11157 if (BrushWidth > 1 || BrushHeight > 1)
11158 {
11159 add_favorite_combo_block(f, Combo, key[KEY_LSHIFT] || key[KEY_RSHIFT]);
11160 break;
11161 }
11162 favorite_combo_modes[fp] = dm_normal;
11163 favorite_combos[fp] = Combo;
11164 saved = false;
11165 }
11166 }
11167
11168 custom_vsync();
11169 refresh(rALL | rFAVORITES);
11170 }
11171
11172 ComboBrush=tempcb;
11173 }
11174 else if(CHECK_CTRL_CMD)
11175 {
11176 int32_t tempcb=ComboBrush;
11177 ComboBrush=0;
11178
11179 while(gui_mouse_b())
11180 {
11181 x=gui_mouse_x();
11182 y=gui_mouse_y();
11183
11184 if(favorite_combos[fp]!=-1)
11185 {
11186 favorite_combo_modes[fp] = dm_normal;
11187 favorite_combos[fp]=-1;
11188 saved=false;
11189 }
11190
11191 custom_vsync();
11192 refresh(rALL | rFAVORITES);
11193 }
11194
11195 ComboBrush=tempcb;
11196 }
11197 else if(key[KEY_ALT] || key[KEY_ALTGR])
11198 {
11199 if(select_favorite())
11200 {
11201 switch(favorite_combo_modes[fp])
11202 {
11203 case dm_alias:
11204 combo_alistpos[current_comboalist]=scrollto_alias(combo_apos);
11205 break;
11206 case dm_cpool:
11207 combo_pool_listpos[current_cpoollist] = scrollto_cpool(combo_pool_pos);
11208 break;
11209 case dm_auto:
11210 combo_auto_listpos[current_cautolist] = scrollto_cauto(combo_auto_pos);
11211 break;
11212 default:
11213 First[current_combolist]=scrollto_cmb(Combo);
11214 }
11215 }
11216 }
11217 else
11218 {
11219 select_favorite();
11220 }
11221 }
11222 else if(rclick)
11223 {
11224 bool valid=select_favorite();
11225
11226 if(valid)
11227 {
11228 int f = favorites_list.rectind(x,y);
11229 int row = f/favorites_list.w;
11230 int col = f%favorites_list.w;
11231 f = (row*FAVORITECOMBO_PER_ROW) + col + (FAVORITECOMBO_PER_PAGE * FavoriteComboPage);
11232 popup_favorites_rc(f, x, y);
11233 }
11234 }
11235 goto domouse_doneclick;
11236 }
11237
11238 //on the commands buttons
11239 int32_t cmd = commands_list.rectind(x,y);
11240 if(cmd > -1)
11241 {
11242 uint hkey = favorite_commands[cmd];
11243 bool shift=(key[KEY_LSHIFT] || key[KEY_RSHIFT]);
11244 bool ctrl=(CHECK_CTRL_CMD);
11245 bool alt=(key[KEY_ALT] || key[KEY_ALTGR]);
11246 bool dis = disabled_hotkey(hkey);
11247 auto& btn = commands_list.subsquare(cmd);
11248 if(!dis||rclick||shift||ctrl||alt)
11249 {
11250 FONT *tfont=font;
11251 font=get_custom_font(CFONT_FAVCMD);
11252 if(do_layer_button_reset(btn.x,btn.y,btn.w,btn.h,
11253 get_hotkey_name(hkey),
11254 selected_hotkey(hkey)?D_SELECTED:0,
11255 true))
11256 {
11257 font=tfont;
11258 if(alt)
11259 {
11260 show_hotkey_info(hkey);
11261 }
11262 else if(ctrl)
11263 {
11264 write_fav_command(cmd,0);
11265 }
11266 else if(rclick || shift || hkey==ZQKEY_NULL_KEY)
11267 {
11268 if(auto newkey = select_fav_command())
11269 write_fav_command(cmd,*newkey);
11270 }
11271 else
11272 {
11273 run_hotkey(hkey);
11274 }
11275 }
11276
11277 font=tfont;
11278 }
11279 goto domouse_doneclick;
11280 }
11281 }
11282
11283 domouse_doneclick:
11284 mouse_down |= mb&3;
11285
11286 if(mouse_z!=0)
11287 {
11288 int32_t z=0;
11289
11290 for(int32_t j=0; j<num_combo_cols; ++j)
11291 {
11292 z=abs(mouse_z);
11293
11294 if(key[KEY_ALT]||key[KEY_ALTGR])
11295 {
11296 z*=combolist[j].h;
11297 }
11298
11299
11300 if(draw_mode == dm_alias)
11301 {
11302 if(comboaliaslist[j].rect(x,y))
11303 {
11304 if(mouse_z<0) //scroll down
11305 {
11306 combo_alistpos[current_comboalist] = zc_min(MAXCOMBOALIASES - comboaliaslist[j].w*comboaliaslist[j].h,
11307 combo_alistpos[current_comboalist]+comboaliaslist[j].w*z);
11308 }
11309 else //scroll up
11310 {
11311 if(combo_alistpos[current_comboalist]>0)
11312 {
11313 combo_alistpos[current_comboalist]-=zc_min(combo_alistpos[current_comboalist],comboaliaslist[j].w*z);
11314 }
11315 }
11316 goto domouse_donez;
11317 }
11318 }
11319 else if(draw_mode == dm_cpool)
11320 {
11321 if(comboaliaslist[j].rect(x,y))
11322 {
11323 if(mouse_z<0) //scroll down
11324 {
11325 combo_pool_listpos[current_cpoollist] = zc_min(MAXCOMBOPOOLS - comboaliaslist[j].w*comboaliaslist[j].h,
11326 combo_pool_listpos[current_cpoollist]+comboaliaslist[j].w*z);
11327 }
11328 else //scroll up
11329 {
11330 if(combo_pool_listpos[current_cpoollist]>0)
11331 {
11332 combo_pool_listpos[current_cpoollist]-=zc_min(combo_pool_listpos[current_cpoollist],comboaliaslist[j].w*z);
11333 }
11334 }
11335 goto domouse_donez;
11336 }
11337 }
11338 else if (draw_mode == dm_auto)
11339 {
11340 if (comboaliaslist[j].rect(x, y))
11341 {
11342 if (mouse_z < 0) //scroll down
11343 {
11344 combo_auto_listpos[current_cautolist] = zc_min(MAXAUTOCOMBOS - comboaliaslist[j].w * comboaliaslist[j].h,
11345 combo_auto_listpos[current_cautolist] + comboaliaslist[j].w * z);
11346 }
11347 else //scroll up
11348 {
11349 if (combo_auto_listpos[current_cautolist] > 0)
11350 {
11351 combo_auto_listpos[current_cautolist] -= zc_min(combo_auto_listpos[current_cautolist], comboaliaslist[j].w * z);
11352 }
11353 }
11354 goto domouse_donez;
11355 }
11356 }
11357 else
11358 {
11359 if(combolist[j].rect(x,y))
11360 {
11361 if(mouse_z<0) //scroll down
11362 {
11363 First[current_combolist] = zc_min(MAXCOMBOS-combolist[j].w*combolist[j].h,
11364 First[current_combolist] + combolist[j].w*z);
11365 }
11366 else //scroll up
11367 {
11368 if(First[current_combolist]>0)
11369 {
11370 First[current_combolist]-=zc_min(First[current_combolist],combolist[j].w*z);
11371 }
11372 }
11373 goto domouse_donez;
11374 }
11375 }
11376 }
11377
11378 z=abs(mouse_z);
11379
11380 if(real_mini.rect(x,y))
11381 {
11382 for(int32_t i=0; i<z; ++i)
11383 {
11384 if(mouse_z>0) onIncMap();
11385 else onDecMap();
11386 }
11387 goto domouse_donez;
11388 }
11389
11390 if(is_compact && compact_square_panels
11391 && squares_panel.rect(x,y))
11392 {
11393 cycle_compact_sqr(mouse_z < 0);
11394 goto domouse_donez;
11395 }
11396 domouse_donez:
11397 position_mouse_z(0);
11398 }
11399 font = tfont;
11400 }
11401
11402 int32_t d_viewpal_proc(int32_t msg, DIALOG *d, int32_t c)
11403 {
11404 int32_t ret = d_bitmap_proc(msg, d, c);
11405 char* buf = (char*)d->dp2; //buffer to store the color code in
11406 DIALOG* d2 = (DIALOG*)d->dp3; //DIALOG* to update the text proc
11407 if(!buf)
11408 return ret;
11409 switch(msg)
11410 {
11411 case MSG_IDLE:
11412 case MSG_GOTMOUSE:
11413 case MSG_LOSTMOUSE:
11414 break;
11415 default:
11416 return ret;
11417 }
11418 char t[16];
11419 memcpy(t, buf, 16);
11420 int32_t x = gui_mouse_x() - d->x;
11421 int32_t y = gui_mouse_y() - d->y;
11422 if(msg != MSG_LOSTMOUSE && isinRect(x, y, 0, 0, d->w-1, d->h-1))
11423 {
11424 float palscale = 1.5;
11425 for(int32_t i = 0; i<256; ++i)
11426 if(isinRect(x,y,(int32_t)(((i&31)<<3)*palscale),(int32_t)(((i&0xE0)>>2)*palscale), (int32_t)((((i&31)<<3)+7)*palscale),(int32_t)((((i&0xE0)>>2)+7)*palscale)))
11427 {
11428 sprintf(buf, "0x%02X (%03d) ", i, i); //Extra spaces to increase drawn width, so it draws the blank area
11429 break;
11430 }
11431 }
11432 else memset(buf, ' ', 15);
11433 if(strcmp(buf, t) && d2 && d2->proc == jwin_text_proc && d2->dp == d->dp2)
11434 object_message(d2, MSG_DRAW, 0);
11435 return ret;
11436 }
11437
11438 static DIALOG showpal_dlg[] =
11439 {
11440 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
11441 { jwin_win_proc, 24, 68, 272, 119, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "View Palette", NULL, NULL },
11442 { jwin_frame_proc, 30, 76+16, 260, 68, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
11443 { d_viewpal_proc, 32, 76+18, 256, 64, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11444 { jwin_text_proc, 32+8,76+18+66, 20, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
11445 { jwin_button_proc, 130, 144+18, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
11446 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11447 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
11448 };
11449
11450 int32_t onShowPal()
11451 {
11452 float palscale = 1.5;
11453
11454 BITMAP *palbmp = create_bitmap_ex(8,(int32_t)(256*palscale),(int32_t)(64*palscale));
11455
11456 if(!palbmp)
11457 return D_O_K;
11458 clear_to_color(palbmp,jwin_pal[jcBOX]); //If not cleared, random static appears between swatches! -E
11459 showpal_dlg[0].dp2=get_zc_font(font_lfont);
11460
11461 for(int32_t i=0; i<256; i++)
11462 rectfill(palbmp,(int32_t)(((i&31)<<3)*palscale),(int32_t)(((i&0xE0)>>2)*palscale), (int32_t)((((i&31)<<3)+7)*palscale),(int32_t)((((i&0xE0)>>2)+7)*palscale),i);
11463 showpal_dlg[2].dp=(void *)palbmp;
11464 char buf[16] = {0};
11465 showpal_dlg[2].dp2=(void *)buf;
11466 showpal_dlg[2].dp3=(void *)&(showpal_dlg[3]);
11467 showpal_dlg[3].dp=(void *)buf;
11468 showpal_dlg[3].dp2=(void *)get_zc_font(font_deffont);
11469
11470 large_dialog(showpal_dlg);
11471 do_zqdialog(showpal_dlg,2);
11472 destroy_bitmap(palbmp);
11473 return D_O_K;
11474 }
11475
11476 static DIALOG csetfix_dlg[] =
11477 {
11478 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
11479 { jwin_win_proc, 72, 80, 176+1, 96+1, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "CSet Fix", NULL, NULL },
11480 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11481 { jwin_radio_proc, 104+22, 108, 80+1, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "Full Screen", NULL, NULL },
11482 { jwin_radio_proc, 104+22, 118+2, 80+1, 8+1, vc(14), vc(1), 0, D_SELECTED, 0, 0, (void *) "Dungeon Floor", NULL, NULL },
11483 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
11484 { jwin_check_proc, 104+22, 128+4, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, (void *) "All Layers", NULL, NULL },
11485 { jwin_button_proc, 90, 152, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
11486 { jwin_button_proc, 170, 152, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
11487 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
11488 };
11489
11490 int32_t onCSetFix()
11491 {
11492 restore_mouse();
11493 csetfix_dlg[0].dp2=get_zc_font(font_lfont);
11494 int32_t s=2,x2=14,y2=9;
11495
11496 large_dialog(csetfix_dlg);
11497
11498 if(do_zqdialog(csetfix_dlg,-1)==6)
11499 {
11500 if(csetfix_dlg[2].flags&D_SELECTED)
11501 {
11502 s=0;
11503 x2=16;
11504 y2=11;
11505 }
11506
11507 if(csetfix_dlg[5].flags&D_SELECTED)
11508 {
11509 /*
11510 int32_t drawmap, drawscr;
11511 if (CurrentLayer==0)
11512 {
11513 drawmap=Map.getCurrMap();
11514 drawscr=Map.getCurrScr();
11515 }
11516 else
11517 {
11518 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
11519 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
11520 }
11521 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
11522 if(!draw_mapscr) return;
11523 saved=false;
11524 Map.Ugo();
11525
11526 if(!(draw_mapscr->valid&mVALID))
11527 {
11528 Map.CurrScr()->valid|=mVALID;
11529 draw_mapscr->valid|=mVALID;
11530 Map.setcolor(Color);
11531 }
11532 for(int32_t i=0; i<176; i++)
11533 {
11534 draw_mapscr->data[i]=Combo;
11535 draw_mapscr->cset[i]=CSet;
11536 }
11537 refresh(rMAP+rSCRMAP);
11538 */
11539 }
11540
11541 Map.StartListCommand();
11542 for(int32_t y=s; y<y2; y++)
11543 {
11544 for(int32_t x=s; x<x2; x++)
11545 {
11546 Map.DoSetComboCommand(Map.getCurrMap(), Map.getCurrScr(), (y<<4)+x, -1, CSet);
11547 }
11548 }
11549 Map.FinishListCommand();
11550
11551 refresh(rMAP);
11552 saved = false;
11553 }
11554
11555 return D_O_K;
11556 }
11557 static bool doAllSolidWater()
11558 {
11559 for(int32_t i=0; i < MAXCOMBOS; ++i)
11560 {
11561 if(combo_class_buf[combobuf[i].type].water!=0)
11562 {
11563 combobuf[i].walk |= 0x0F; //Solid
11564 }
11565 }
11566 return true;
11567 }
11568 static bool doNoSolidWater()
11569 {
11570 for(int32_t i=0; i < MAXCOMBOS; ++i)
11571 {
11572 if(combo_class_buf[combobuf[i].type].water!=0)
11573 {
11574 combobuf[i].walk &= ~0x0F; //Non-solid
11575 }
11576 }
11577 return true;
11578 }
11579 int32_t onWaterSolidity()
11580 {
11581 AlertFuncDialog("Water Conversion",
11582 "Forcibly set the solidity of all 'Liquid' combos in the quest?",
11583 "",
11584 3, 2, //3 buttons, where buttons[2] is focused
11585 { "Solid", "Non-Solid", "Cancel" },
11586 { doAllSolidWater, doNoSolidWater, nullptr }
11587 ).show();
11588 return D_O_K;
11589 }
11590
11591 static bool doAllEffectSquare()
11592 {
11593 for(int32_t i=0; i < MAXCOMBOS; ++i)
11594 {
11595 combobuf[i].walk |= 0xF0; //Effect
11596 }
11597 return true;
11598 }
11599 static bool doBlankEffectSquare()
11600 {
11601 for(int32_t i=0; i < MAXCOMBOS; ++i)
11602 {
11603 if(combobuf[i].is_blank(true))
11604 {
11605 combobuf[i].walk |= 0xF0; //Effect
11606 }
11607 }
11608 return true;
11609 }
11610
11611 int32_t onEffectFix()
11612 {
11613 AlertFuncDialog("Effect Square Conversion",
11614 "Forcibly fill the green effect square of all combos in the quest?",
11615 "",
11616 3, 2, //3 buttons, where buttons[2] is focused
11617 { "All", "Blank Only", "Cancel" },
11618 { doAllEffectSquare, doBlankEffectSquare, nullptr }
11619 ).show();
11620 return D_O_K;
11621 }
11622
11623 byte* getPalPointer(int32_t pal, int32_t cset)
11624 {
11625 if (pal < 0) return colordata + CSET(cset)*3;
11626 byte* ret = colordata + CSET(pal*pdLEVEL+poLEVEL)*3;
11627 switch(cset)
11628 {
11629 case 2: case 3: case 4:
11630 return ret + CSET(cset-2)*3;
11631 case 9:
11632 return ret + CSET(3)*3;
11633 case 1:
11634 return ret + CSET(13)*3;
11635 case 5:
11636 return ret + CSET(14)*3;
11637 case 7:
11638 return ret + CSET(15)*3;
11639 case 8:
11640 return ret + CSET(16)*3;
11641 }
11642 return NULL;
11643 }
11644
11645 void copyCSet(int32_t destpal, int32_t destcset, int32_t srcpal, int32_t srccset)
11646 {
11647 byte* dest = getPalPointer(destpal, destcset);
11648 byte* src = getPalPointer(srcpal, srccset);
11649 if (dest && src)
11650 {
11651 memcpy(dest, src, 16*3);
11652 }
11653 }
11654
11655 void setColorPalette(int32_t flags, int32_t lowpal, int32_t highpal)
11656 {
11657 for (auto q = lowpal; q <= highpal; ++q)
11658 {
11659 for (auto c = 0; c < 12; ++c)
11660 {
11661 if (!(flags&(1<<c))) continue;
11662 copyCSet(q, c, -1, c);
11663 }
11664 }
11665 }
11666
11667 void setPitDamage(int32_t flags, int32_t lowcombo, int32_t highcombo, int32_t damage)
11668 {
11669 for(int32_t i=lowcombo; i < highcombo; ++i)
11670 {
11671 if((combobuf[i].type == cPITFALL && (flags & (1<<0)))
11672 || (combobuf[i].type == cWATER && !(combobuf[i].usrflags & (1<<0)) && (flags & (1<<1)))
11673 || (combobuf[i].type == cWATER && (combobuf[i].usrflags & (1<<0)) && (flags & (1<<2))))
11674 {
11675 if ((combobuf[i].type != cPITFALL || (flags & (1<<9)) || !(combobuf[i].usrflags & (1<<0)))
11676 && ((flags & (1<<8)) || combobuf[i].attributes[0] == 0))
11677 combobuf[i].attributes[0] = damage*10000;
11678 }
11679 }
11680 }
11681
11682 static DIALOG template_dlg[] =
11683 {
11684 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
11685 { jwin_win_proc, 72, 80, 176+1, 116+1, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "NES Dungeon Template", NULL, NULL },
11686 { d_comboframe_proc, 178, 122+3, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
11687 { d_combo_proc, 180, 124+3, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11688 // { d_bitmap_proc, 180, 104, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11689 { jwin_radio_proc, 104+33, 128+3, 64+1, 8+1, vc(14), vc(1), 0, D_SELECTED, 0, 0, (void *) "Floor:", NULL, NULL },
11690 { jwin_radio_proc, 104+33, 148+3, 64+1, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "No Floor", NULL, NULL },
11691 { jwin_button_proc, 90, 172, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
11692 { jwin_button_proc, 170, 172, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
11693 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11694 { jwin_text_proc, 104, 102, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "This copies the contents of", NULL, NULL },
11695 { jwin_text_proc, 104, 112, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "screen 83 of the current map.", NULL, NULL },
11696 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
11697 };
11698
11699 int32_t onTemplate()
11700 {
11701 static bool donethis=false;
11702
11703 if(!donethis||!(key[KEY_LSHIFT]||key[KEY_RSHIFT]))
11704 {
11705 template_dlg[2].d1=Combo;
11706 template_dlg[2].fg=CSet;
11707 donethis=true;
11708 }
11709
11710 restore_mouse();
11711
11712 if(Map.getCurrScr()==TEMPLATE)
11713 return D_O_K;
11714
11715 // BITMAP *floor_bmp = create_bitmap_ex(8,16,16);
11716 // if(!floor_bmp) return D_O_K;
11717 template_dlg[0].dp2=get_zc_font(font_lfont);
11718 // put_combo(floor_bmp,0,0,Combo,CSet,0,0);
11719 // template_dlg[2].dp=floor_bmp;
11720
11721 large_dialog(template_dlg);
11722
11723 if(do_zqdialog(template_dlg,-1)==5)
11724 {
11725 saved=false;
11726 Map.DoTemplateCommand((template_dlg[3].flags==D_SELECTED) ? template_dlg[2].d1 : -1, template_dlg[2].fg, Map.getCurrScr());
11727 refresh(rMAP+rSCRMAP);
11728 }
11729
11730 // destroy_bitmap(floor_bmp);
11731 return D_O_K;
11732 }
11733
11734 static DIALOG cpage_dlg[] =
11735 {
11736 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
11737 { jwin_win_proc, 72, 20, 176+1, 212+1, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
11738 { d_ctext2_proc, 160, 28, 0, 8, vc(15), vc(1), 0, 0, 0, 0, (void *) "Combo Page", NULL, NULL },
11739 { jwin_button_proc, 90, 182, 61, 21, vc(14), vc(1), 's', D_EXIT, 0, 0, (void *) "&Set", NULL, NULL },
11740 { jwin_button_proc, 170, 182, 61, 21, vc(14), vc(1), 'c', D_EXIT, 0, 0, (void *) "&Cancel", NULL, NULL },
11741 { jwin_button_proc, 90, 210, 61, 21, vc(14), vc(1), 'a', D_EXIT, 0, 0, (void *) "Set &All", NULL, NULL },
11742 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
11743 // 6
11744 { jwin_radio_proc, 76, 44, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "0" , NULL, NULL },
11745 { jwin_radio_proc, 76, 52, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "1" , NULL, NULL },
11746 { jwin_radio_proc, 76, 60, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "2" , NULL, NULL },
11747 { jwin_radio_proc, 76, 68, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "3" , NULL, NULL },
11748 { jwin_radio_proc, 76, 76, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "4" , NULL, NULL },
11749 { jwin_radio_proc, 76, 84, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "5" , NULL, NULL },
11750 { jwin_radio_proc, 76, 92, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "6" , NULL, NULL },
11751 { jwin_radio_proc, 76, 100, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "7" , NULL, NULL },
11752 { jwin_radio_proc, 76, 108, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "8" , NULL, NULL },
11753 { jwin_radio_proc, 76, 116, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "9" , NULL, NULL },
11754 { jwin_radio_proc, 76, 124, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "10" , NULL, NULL },
11755 { jwin_radio_proc, 76, 132, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "11" , NULL, NULL },
11756 { jwin_radio_proc, 76, 140, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "12" , NULL, NULL },
11757 { jwin_radio_proc, 76, 148, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "13" , NULL, NULL },
11758 { jwin_radio_proc, 76, 156, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "14" , NULL, NULL },
11759 { jwin_radio_proc, 76, 164, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "15" , NULL, NULL },
11760 { jwin_radio_proc, 120, 44, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "16" , NULL, NULL },
11761 { jwin_radio_proc, 120, 52, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "17" , NULL, NULL },
11762 { jwin_radio_proc, 120, 60, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "18" , NULL, NULL },
11763 { jwin_radio_proc, 120, 68, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "19" , NULL, NULL },
11764 { jwin_radio_proc, 120, 76, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "20" , NULL, NULL },
11765 { jwin_radio_proc, 120, 84, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "21" , NULL, NULL },
11766 { jwin_radio_proc, 120, 92, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "22" , NULL, NULL },
11767 { jwin_radio_proc, 120, 100, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "23" , NULL, NULL },
11768 { jwin_radio_proc, 120, 108, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "24" , NULL, NULL },
11769 { jwin_radio_proc, 120, 116, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "25" , NULL, NULL },
11770 { jwin_radio_proc, 120, 124, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "26" , NULL, NULL },
11771 { jwin_radio_proc, 120, 132, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "27" , NULL, NULL },
11772 { jwin_radio_proc, 120, 140, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "28" , NULL, NULL },
11773 { jwin_radio_proc, 120, 148, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "29" , NULL, NULL },
11774 { jwin_radio_proc, 120, 156, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "30" , NULL, NULL },
11775 { jwin_radio_proc, 120, 164, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "31" , NULL, NULL },
11776 { jwin_radio_proc, 164, 44, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "32" , NULL, NULL },
11777 { jwin_radio_proc, 164, 52, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "33" , NULL, NULL },
11778 { jwin_radio_proc, 164, 60, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "34" , NULL, NULL },
11779 { jwin_radio_proc, 164, 68, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "35" , NULL, NULL },
11780 { jwin_radio_proc, 164, 76, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "36" , NULL, NULL },
11781 { jwin_radio_proc, 164, 84, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "37" , NULL, NULL },
11782 { jwin_radio_proc, 164, 92, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "38" , NULL, NULL },
11783 { jwin_radio_proc, 164, 100, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "39" , NULL, NULL },
11784 { jwin_radio_proc, 164, 108, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "40" , NULL, NULL },
11785 { jwin_radio_proc, 164, 116, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "41" , NULL, NULL },
11786 { jwin_radio_proc, 164, 124, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "42" , NULL, NULL },
11787 { jwin_radio_proc, 164, 132, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "43" , NULL, NULL },
11788 { jwin_radio_proc, 164, 140, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "44" , NULL, NULL },
11789 { jwin_radio_proc, 164, 148, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "45" , NULL, NULL },
11790 { jwin_radio_proc, 164, 156, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "46" , NULL, NULL },
11791 { jwin_radio_proc, 164, 164, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "47" , NULL, NULL },
11792 { jwin_radio_proc, 208, 44, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "48" , NULL, NULL },
11793 { jwin_radio_proc, 208, 52, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "49" , NULL, NULL },
11794 { jwin_radio_proc, 208, 60, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "50" , NULL, NULL },
11795 { jwin_radio_proc, 208, 68, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "51" , NULL, NULL },
11796 { jwin_radio_proc, 208, 76, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "52" , NULL, NULL },
11797 { jwin_radio_proc, 208, 84, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "53" , NULL, NULL },
11798 { jwin_radio_proc, 208, 92, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "54" , NULL, NULL },
11799 { jwin_radio_proc, 208, 100, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "55" , NULL, NULL },
11800 { jwin_radio_proc, 208, 108, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "56" , NULL, NULL },
11801 { jwin_radio_proc, 208, 116, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "57" , NULL, NULL },
11802 { jwin_radio_proc, 208, 124, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "58" , NULL, NULL },
11803 { jwin_radio_proc, 208, 132, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "59" , NULL, NULL },
11804 { jwin_radio_proc, 208, 140, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "60" , NULL, NULL },
11805 { jwin_radio_proc, 208, 148, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "61" , NULL, NULL },
11806 { jwin_radio_proc, 208, 156, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "62" , NULL, NULL },
11807 { jwin_radio_proc, 208, 164, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "63" , NULL, NULL },
11808 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11809 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
11810 };
11811
11812 int32_t onComboPage()
11813 {
11814 for(int32_t i=0; i<64; i++)
11815 cpage_dlg[i+6].flags = Map.CurrScr()->old_cpage==i?D_SELECTED:0;
11816
11817 int32_t ret = do_zqdialog(cpage_dlg,3);
11818
11819 int32_t p = 0;
11820
11821 for(int32_t i=0; i<64; i++)
11822
11823 if(cpage_dlg[i+6].flags==D_SELECTED)
11824 p=i;
11825
11826 if(ret==2)
11827 {
11828 saved=false;
11829 Map.CurrScr()->old_cpage = p;
11830 }
11831
11832 if(ret==4 && jwin_alert("Confirm Overwrite","Set all combo pages","on this map?",NULL,"&Yes","&No",'y','n',get_zc_font(font_lfont))==1)
11833 {
11834 saved=false;
11835
11836 for(int32_t i=0; i<=TEMPLATE; i++)
11837 Map.Scr(i)->old_cpage = p;
11838 }
11839
11840 refresh(rALL);
11841 return D_O_K;
11842 }
11843
11844 int32_t d_sel_scombo_proc(int32_t msg, DIALOG *d, int32_t c)
11845 {
11846 //these are here to bypass compiler warnings about unused arguments
11847 c=c;
11848
11849 switch(msg)
11850 {
11851 case MSG_CLICK:
11852 while(gui_mouse_b())
11853 {
11854 int32_t x = zc_min(zc_max(gui_mouse_x() - d->x,0)>>4, 15);
11855 int32_t y = zc_min(zc_max(gui_mouse_y() - d->y,0)&0xF0, 160);
11856
11857 if(x+y != d->d1)
11858 {
11859 d->d1 = x+y;
11860 custom_vsync();
11861 d_sel_scombo_proc(MSG_DRAW,d,0);
11862 }
11863 }
11864
11865 break;
11866
11867 case MSG_DRAW:
11868 {
11869 blit((BITMAP*)(d->dp),screen,0,0,d->x,d->y,d->w,d->h);
11870 int32_t x = d->x + (((d->d1)&15)<<4);
11871 int32_t y = d->y + ((d->d1)&0xF0);
11872 rect(screen,x,y,x+15,y+15,vc(15));
11873 }
11874 break;
11875 }
11876
11877 return D_O_K;
11878 }
11879
11880 /*
11881 static DIALOG sel_scombo_dlg[] =
11882 {
11883 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
11884 { jwin_win_proc, 24, 16, 272+1, 216+1, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
11885 { d_sel_scombo_proc, 32, 24, 256, 176, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11886 { jwin_button_proc, 90, 208, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
11887 { jwin_button_proc, 170, 208, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
11888 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11889 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
11890 };
11891
11892 void select_scombo(int32_t &pos)
11893 {
11894 go();
11895 Map.draw_template2(screen2,0,0);
11896 sel_scombo_dlg[1].dp = screen2;
11897 sel_scombo_dlg[1].d1 = pos;
11898
11899 while (gui_mouse_b()) {
11900 //nothing
11901 }
11902
11903 if(do_zqdialog(sel_scombo_dlg,3)==2)
11904 pos = sel_scombo_dlg[1].d1;
11905
11906 comeback();
11907 }
11908 */
11909
11910 static DIALOG cflag_dlg[] =
11911 {
11912 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
11913 8 { jwin_win_proc, 60-12, 40, 200+24, 148, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
11914 8 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11915 8 { jwin_abclist_proc, 72-12-4, 60+4, 176+24+8, 92+3, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, NULL, NULL, NULL },
11916 8 { jwin_button_proc, 70, 163, 51, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
11917 8 { jwin_button_proc, 190, 163, 51, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
11918 8 { jwin_button_proc, 130, 163, 51, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Help", NULL, NULL },
11919 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
11920 };
11921
11922
11923 void questrev_help()
11924 {
11925 jwin_alert("Help","The revision number of your quest.",NULL,NULL,"O&K",NULL,'k',16,get_zc_font(font_lfont));
11926 }
11927
11928 void questminrev_help()
11929 {
11930 jwin_alert("Help","If a player's saved game was from a revision less than the minimum", "revision, they have to restart from the beginning.", "This is useful if you make major changes to your quest.","O&K",NULL,'k',16,get_zc_font(font_lfont));
11931 }
11932
11933 int32_t select_cflag(const char *prompt,int32_t flag)
11934 {
11935 cflag_dlg[0].dp=(void *)prompt;
11936 cflag_dlg[0].dp2=get_zc_font(font_lfont);
11937 GUI::ListData ld = GUI::ZCListData::mapflag(numericalFlags, true);
11938 ListData select_cflag_list = ld.getJWin(&font);
11939 int32_t index = ld.findIndex(flag);
11940 cflag_dlg[2].d1=index;
11941 cflag_dlg[2].dp=(void *) &select_cflag_list;
11942
11943 large_dialog(cflag_dlg);
11944
11945 int32_t ret;
11946
11947 do
11948 {
11949 ret=do_zqdialog(cflag_dlg,2);
11950
11951 if(ret==5)
11952 {
11953 cflag_help(ld.getValue(cflag_dlg[2].d1));
11954 }
11955 }
11956 while(ret==5);
11957
11958 if(ret==0||ret==4)
11959 {
11960 position_mouse_z(0);
11961 return -1;
11962 }
11963
11964 return ld.getValue(cflag_dlg[2].d1);
11965 }
11966
11967 int32_t select_flag(int32_t &f)
11968 {
11969 int32_t ret=select_cflag("Flag Type",f);
11970
11971 if(ret>=0)
11972 {
11973 f=ret;
11974 return true;
11975 }
11976
11977 return false;
11978 }
11979
11980 int32_t d_scombo_proc(int32_t msg,DIALOG *d,int32_t c)
11981 {
11982 //these are here to bypass compiler warnings about unused arguments
11983 c=c;
11984
11985 switch(msg)
11986 {
11987 case MSG_CLICK:
11988 {
11989 int32_t c2=d->d1;
11990 int32_t cs=d->fg;
11991 int32_t f=d->d2;
11992
11993 if(d->bg==1 || (CHECK_CTRL_CMD))
11994 {
11995 while(gui_mouse_b())
11996 {
11997 /* do nothing */
11998 rest(1);
11999 }
12000
12001 if(select_flag(f))
12002 {
12003 d->d2=f;
12004
12005 }
12006 }
12007 else if(key[KEY_LSHIFT])
12008 {
12009 if(gui_mouse_b()&1)
12010 {
12011 d->d1++;
12012
12013 if(d->d1>=MAXCOMBOS) d->d1=0;
12014 }
12015 else if(gui_mouse_b()&2)
12016 {
12017 d->d1--;
12018
12019 if(d->d1<0) d->d1=MAXCOMBOS-1;
12020 }
12021 }
12022 else if(key[KEY_RSHIFT])
12023 {
12024 if(gui_mouse_b()&1)
12025 {
12026 d->fg++;
12027
12028 if(d->fg>11) d->fg=0;
12029 }
12030 else if(gui_mouse_b()&2)
12031 {
12032 d->fg--;
12033
12034 if(d->fg<0) d->fg=11;
12035 }
12036 }
12037 else if(key[KEY_ALT])
12038 {
12039 if(gui_mouse_b()&1)
12040 {
12041 d->d1 = Combo;
12042 d->fg = CSet;
12043 }
12044 }
12045 else
12046 {
12047 if(select_combo_2(c2, cs))
12048 {
12049 d->d1=c2;
12050 d->fg=cs;
12051 }
12052 }
12053
12054 return D_REDRAW;
12055 }
12056 break;
12057
12058 case MSG_DRAW:
12059 d->w = 32;
12060 d->h = 32;
12061
12062 BITMAP *buf = create_bitmap_ex(8,16,16);
12063 BITMAP *bigbmp = create_bitmap_ex(8,d->w,d->h);
12064
12065 if(buf && bigbmp)
12066 {
12067 clear_bitmap(buf);
12068
12069 if(d->bg) //flags only
12070 {
12071 put_flag(buf,0,0,d->d2);
12072 }
12073 else if(d->d1)
12074 {
12075 putcombo(buf,0,0,d->d1,d->fg);
12076
12077 if(Flags&cFLAGS)
12078 put_flags(buf,0,0,d->d1,d->fg,cFLAGS,d->d2);
12079 }
12080
12081 stretch_blit(buf, bigbmp, 0,0, 16, 16, 0, 0, d->w, d->h);
12082 destroy_bitmap(buf);
12083 blit(bigbmp,screen,0,0,d->x-1,d->y-1,d->w,d->h);
12084 destroy_bitmap(bigbmp);
12085 }
12086
12087
12088 /*BITMAP *buf = create_bitmap_ex(8,16,16);
12089 if(buf)
12090 {
12091 clear_bitmap(buf);
12092 if(d->d1)
12093 putcombo(buf,0,0,d->d1,d->fg);
12094
12095 blit(buf,screen,0,0,d->x,d->y,d->w,d->h);
12096 destroy_bitmap(buf);
12097 }*/
12098 break;
12099 }
12100
12101 return D_O_K;
12102 }
12103
12104 /*int32_t d_scombo2_proc(int32_t msg, DIALOG *d, int32_t c)
12105 {
12106 //these are here to bypass compiler warnings about unused arguments
12107 c=c;
12108
12109 switch(msg)
12110 {
12111 case MSG_CLICK:
12112 if (CHECK_CTRL_CMD)
12113 {
12114 select_scombo(d->d1);
12115 }
12116 else
12117 {
12118 select_scombo(d->d1);
12119 }
12120 d_scombo_proc(MSG_DRAW,d,0);
12121 break;
12122
12123
12124 case MSG_DRAW:
12125 BITMAP *buf = create_bitmap_ex(8,16,16);
12126 if(buf)
12127 {
12128 clear_bitmap(buf);
12129 Map.draw_secret2(buf,d->d1);
12130 blit(buf,screen,0,0,d->x,d->y,16,16);
12131 destroy_bitmap(buf);
12132 }
12133 break;
12134 }
12135
12136 return D_O_K;
12137 }*/
12138
12139 int32_t onSecretF();
12140
12141 static int32_t secret_burn_list[] =
12142 {
12143 // dialog control number
12144 4, 5, 6, 7, 48, 49, 50, 51, 92, 93, 94, 95, -1
12145 };
12146
12147 static int32_t secret_arrow_list[] =
12148 {
12149 // dialog control number
12150 8, 9, 10, 52, 53, 54, 96, 97, 98, -1
12151 };
12152
12153 static int32_t secret_bomb_list[] =
12154 {
12155 // dialog control number
12156 11, 12, 55, 56, 99, 100, -1
12157 };
12158
12159 static int32_t secret_boomerang_list[] =
12160 {
12161 // dialog control number
12162 13, 14, 15, 57, 58, 59, 101, 102, 103, -1
12163 };
12164
12165 static int32_t secret_magic_list[] =
12166 {
12167 // dialog control number
12168 16, 17, 60, 61, 104, 105, -1
12169 };
12170
12171 static int32_t secret_sword_list[] =
12172 {
12173 // dialog control number
12174 18, 19, 20, 21, 22, 23, 24, 25, 62, 63, 64, 65, 66, 67, 68, 69, 106, 107, 108, 109, 110, 111, 112, 113, -1
12175 };
12176
12177 static int32_t secret_misc_list[] =
12178 {
12179 // dialog control number
12180 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, -1
12181 };
12182
12183 static TABPANEL secret_tabs[] =
12184 {
12185 // (text)
12186 { (char *)"Burn", D_SELECTED, secret_burn_list, 0, NULL },
12187 { (char *)"Arrow", 0, secret_arrow_list, 0, NULL },
12188 { (char *)"Bomb", 0, secret_bomb_list, 0, NULL },
12189 { (char *)"Boomerang", 0, secret_boomerang_list, 0, NULL },
12190 { (char *)"Magic", 0, secret_magic_list, 0, NULL },
12191 { (char *)"Sword", 0, secret_sword_list, 0, NULL },
12192 { (char *)"Misc", 0, secret_misc_list, 0, NULL },
12193 { NULL, 0, NULL, 0, NULL }
12194 };
12195
12196 static DIALOG secret_dlg[] =
12197 {
12198 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
12199 { jwin_win_proc, 0, 0, 301, 212, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
12200 { jwin_tab_proc, 6, 25, 289, 156, 0, 0, 0, 0, 0, 0, (void *) secret_tabs, NULL, (void *)secret_dlg },
12201 { jwin_button_proc, 80, 187, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
12202 { jwin_button_proc, 160, 187, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
12203 // 4
12204 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Any Fire", NULL, NULL },
12205 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Strong Fire", NULL, NULL },
12206 { jwin_text_proc, 12, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Magic Fire", NULL, NULL },
12207 { jwin_text_proc, 12, 119, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Divine Fire", NULL, NULL },
12208 //8
12209 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Wooden Arrow", NULL, NULL },
12210 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Silver Arrow", NULL, NULL },
12211 { jwin_text_proc, 12, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Golden Arrow", NULL, NULL },
12212 //11
12213 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Bomb", NULL, NULL },
12214 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Super Bomb", NULL, NULL },
12215 //13
12216 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Wooden Boomerang", NULL, NULL },
12217 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Magic Boomerang", NULL, NULL },
12218 { jwin_text_proc, 12, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Fire Boomerang", NULL, NULL },
12219 //16
12220 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Wand Magic", NULL, NULL },
12221 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Reflected Magic", NULL, NULL },
12222 //18
12223 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Sword", NULL, NULL },
12224 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "White Sword", NULL, NULL },
12225 { jwin_text_proc, 12, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Magic Sword", NULL, NULL },
12226 { jwin_text_proc, 12, 119, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Master Sword", NULL, NULL },
12227 { jwin_text_proc, 160, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Sword Beam", NULL, NULL },
12228 { jwin_text_proc, 160, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "White Sword Beam", NULL, NULL },
12229 { jwin_text_proc, 160, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Magic Sword Beam", NULL, NULL },
12230 { jwin_text_proc, 160, 119, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Master Sword Beam", NULL, NULL },
12231 //26
12232 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Stairs", NULL, NULL },
12233 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Reflected Fireball", NULL, NULL },
12234 { jwin_text_proc, 12, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Hookshot", NULL, NULL },
12235 { jwin_text_proc, 12, 119, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Wand", NULL, NULL },
12236 { jwin_text_proc, 12, 141, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Hammer", NULL, NULL },
12237 { jwin_text_proc, 12, 163, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Any Weapon", NULL, NULL },
12238 //32
12239 { jwin_ctext_proc, 235, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Flags 16-31", NULL, NULL },
12240 { jwin_text_proc, 87, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Secrets->Next (Flag only)", NULL, NULL },
12241 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 03", NULL, NULL },
12242 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 04", NULL, NULL },
12243 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 05", NULL, NULL },
12244 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 06", NULL, NULL },
12245 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 07", NULL, NULL },
12246 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 08", NULL, NULL },
12247 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 09", NULL, NULL },
12248 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 10", NULL, NULL },
12249 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 11", NULL, NULL },
12250 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 12", NULL, NULL },
12251 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 13", NULL, NULL },
12252 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 14", NULL, NULL },
12253 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 15", NULL, NULL },
12254 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 16", NULL, NULL },
12255 //48 (burn)
12256 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12257 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12258 { jwin_frame_proc, 108, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12259 { jwin_frame_proc, 108, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12260 //52 (arrow)
12261 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12262 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12263 { jwin_frame_proc, 108, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12264 //55 (bomb)
12265 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12266 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12267 //57 (boomerang)
12268 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12269 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12270 { jwin_frame_proc, 108, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12271 //60 (magic)
12272 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12273 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12274 //62 (sword)
12275 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12276 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12277 { jwin_frame_proc, 108, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12278 { jwin_frame_proc, 108, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12279 { jwin_frame_proc, 256, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12280 { jwin_frame_proc, 256, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12281 { jwin_frame_proc, 256, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12282 { jwin_frame_proc, 256, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12283 //70 (misc)
12284 { jwin_frame_proc, 63, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12285 { jwin_frame_proc, 63, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12286 { jwin_frame_proc, 63, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12287 { jwin_frame_proc, 63, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12288 { jwin_frame_proc, 63, 135, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12289 { jwin_frame_proc, 63, 157, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12290 //76 (16-32)
12291 { jwin_frame_proc, 192, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12292 { jwin_frame_proc, 214, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12293 { jwin_frame_proc, 236, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12294 { jwin_frame_proc, 258, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12295 { jwin_frame_proc, 192, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12296 { jwin_frame_proc, 214, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12297 { jwin_frame_proc, 236, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12298 { jwin_frame_proc, 258, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12299 { jwin_frame_proc, 192, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12300 { jwin_frame_proc, 214, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12301 { jwin_frame_proc, 236, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12302 { jwin_frame_proc, 258, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12303 { jwin_frame_proc, 192, 135, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12304 { jwin_frame_proc, 214, 135, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12305 { jwin_frame_proc, 236, 135, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12306 { jwin_frame_proc, 258, 135, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12307
12308 //92 (burn)
12309 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12310 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12311 { d_scombo_proc, 110, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12312 { d_scombo_proc, 110, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12313 //96 (arrow)
12314 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12315 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12316 { d_scombo_proc, 110, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12317 //99 (bomb)
12318 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12319 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12320 //101 (boomerang)
12321 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12322 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12323 { d_scombo_proc, 110, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12324 //104 (magic)
12325 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12326 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12327 //106 (sword)
12328 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12329 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12330 { d_scombo_proc, 110, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12331 { d_scombo_proc, 110, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12332 { d_scombo_proc, 258, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12333 { d_scombo_proc, 258, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12334 { d_scombo_proc, 258, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12335 { d_scombo_proc, 258, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12336 //114 (misc)
12337 { d_scombo_proc, 65, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12338 { d_scombo_proc, 65, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12339 { d_scombo_proc, 65, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12340 { d_scombo_proc, 65, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12341 { d_scombo_proc, 65, 137, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12342 { d_scombo_proc, 65, 159, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12343 //120 (16-32)
12344 { d_scombo_proc, 194, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12345 { d_scombo_proc, 216, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12346 { d_scombo_proc, 238, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12347 { d_scombo_proc, 260, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12348 { d_scombo_proc, 194, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12349 { d_scombo_proc, 216, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12350 { d_scombo_proc, 238, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12351 { d_scombo_proc, 260, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12352 { d_scombo_proc, 194, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12353 { d_scombo_proc, 216, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12354 { d_scombo_proc, 238, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12355 { d_scombo_proc, 260, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12356 { d_scombo_proc, 194, 137, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12357 { d_scombo_proc, 216, 137, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12358 { d_scombo_proc, 238, 137, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12359 { d_scombo_proc, 260, 137, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12360 //136 Secrets->Next
12361 { jwin_frame_proc, 158, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12362 { d_scombo_proc, 160, 49, 16, 16, 0, 1, 0, 0, 0, 0, NULL, NULL, NULL },
12363 //138
12364 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
12365 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 'f', 0, 0, 0, (void *) onSecretF, NULL, NULL },
12366 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12367 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
12368 };
12369
12370 int32_t onSecretF()
12371 {
12372 Flags^=cFLAGS;
12373 object_message(secret_dlg+1, MSG_DRAW, 0);
12374 return D_O_K;
12375 }
12376
12377
12378 int32_t onSecretCombo()
12379 {
12380 secret_dlg[0].dp2=get_zc_font(font_lfont);
12381
12382
12383 mapscr *s;
12384
12385 if(CurrentLayer==0)
12386 {
12387 s=Map.CurrScr();
12388 }
12389 else
12390 {
12391 // s=TheMaps[(Map.CurrScr()->layermap[CurrentLayer-1]-1)*MAPSCRS+(Map.CurrScr()->layerscreen[CurrentLayer-1])];
12392 s=Map.AbsoluteScr((Map.CurrScr()->layermap[CurrentLayer-1]-1), (Map.CurrScr()->layerscreen[CurrentLayer-1]));
12393 }
12394 if(!s) return D_O_K;
12395
12396 char secretcombonumstr[27];
12397 sprintf(secretcombonumstr,"Secret Combos for Layer %d", CurrentLayer);
12398 secret_dlg[0].dp = secretcombonumstr;
12399
12400 secret_dlg[92].d1 = s->secretcombo[sBCANDLE];
12401 secret_dlg[92].fg = s->secretcset[sBCANDLE];
12402 secret_dlg[92].d2 = s->secretflag[sBCANDLE];
12403
12404 secret_dlg[93].d1 = s->secretcombo[sRCANDLE];
12405 secret_dlg[93].fg = s->secretcset[sRCANDLE];
12406 secret_dlg[93].d2 = s->secretflag[sRCANDLE];
12407
12408 secret_dlg[94].d1 = s->secretcombo[sWANDFIRE];
12409 secret_dlg[94].fg = s->secretcset[sWANDFIRE];
12410 secret_dlg[94].d2 = s->secretflag[sWANDFIRE];
12411
12412 secret_dlg[95].d1 = s->secretcombo[sDIVINEFIRE];
12413 secret_dlg[95].fg = s->secretcset[sDIVINEFIRE];
12414 secret_dlg[95].d2 = s->secretflag[sDIVINEFIRE];
12415
12416 secret_dlg[96].d1 = s->secretcombo[sARROW];
12417 secret_dlg[96].fg = s->secretcset[sARROW];
12418 secret_dlg[96].d2 = s->secretflag[sARROW];
12419
12420 secret_dlg[97].d1 = s->secretcombo[sSARROW];
12421 secret_dlg[97].fg = s->secretcset[sSARROW];
12422 secret_dlg[97].d2 = s->secretflag[sSARROW];
12423
12424 secret_dlg[98].d1 = s->secretcombo[sGARROW];
12425 secret_dlg[98].fg = s->secretcset[sGARROW];
12426 secret_dlg[98].d2 = s->secretflag[sGARROW];
12427
12428 secret_dlg[99].d1 = s->secretcombo[sBOMB];
12429 secret_dlg[99].fg = s->secretcset[sBOMB];
12430 secret_dlg[99].d2 = s->secretflag[sBOMB];
12431
12432 secret_dlg[100].d1 = s->secretcombo[sSBOMB];
12433 secret_dlg[100].fg = s->secretcset[sSBOMB];
12434 secret_dlg[100].d2 = s->secretflag[sSBOMB];
12435
12436 for(int32_t i=0; i<3; i++)
12437 {
12438 secret_dlg[101+i].d1 = s->secretcombo[sBRANG+i];
12439 secret_dlg[101+i].fg = s->secretcset[sBRANG+i];
12440 secret_dlg[101+i].d2 = s->secretflag[sBRANG+i];
12441 }
12442
12443 for(int32_t i=0; i<2; i++)
12444 {
12445 secret_dlg[104+i].d1 = s->secretcombo[sWANDMAGIC+i];
12446 secret_dlg[104+i].fg = s->secretcset[sWANDMAGIC+i];
12447 secret_dlg[104+i].d2 = s->secretflag[sWANDMAGIC+i];
12448 }
12449
12450 for(int32_t i=0; i<8; i++)
12451 {
12452 secret_dlg[106+i].d1 = s->secretcombo[sSWORD+i];
12453 secret_dlg[106+i].fg = s->secretcset[sSWORD+i];
12454 secret_dlg[106+i].d2 = s->secretflag[sSWORD+i];
12455 }
12456
12457 secret_dlg[114].d1 = s->secretcombo[sSTAIRS];
12458 secret_dlg[114].fg = s->secretcset[sSTAIRS];
12459 secret_dlg[114].d2 = s->secretflag[sSTAIRS];
12460
12461 secret_dlg[115].d1 = s->secretcombo[sREFFIREBALL];
12462 secret_dlg[115].fg = s->secretcset[sREFFIREBALL];
12463 secret_dlg[115].d2 = s->secretflag[sREFFIREBALL];
12464
12465 for(int32_t i=0; i<4; i++)
12466 {
12467 secret_dlg[116+i].d1 = s->secretcombo[sHOOKSHOT+i];
12468 secret_dlg[116+i].fg = s->secretcset[sHOOKSHOT+i];
12469 secret_dlg[116+i].d2 = s->secretflag[sHOOKSHOT+i];
12470 }
12471
12472 for(int32_t i=0; i<16; i++)
12473 {
12474 secret_dlg[120+i].d1 = s->secretcombo[sSECRET01+i];
12475 secret_dlg[120+i].fg = s->secretcset[sSECRET01+i];
12476 secret_dlg[120+i].d2 = s->secretflag[sSECRET01+i];
12477 }
12478
12479 //Sec->Next doesn't have a combo/cset value associated
12480 secret_dlg[137].d1 = 0;
12481 secret_dlg[137].fg = 0;
12482 secret_dlg[137].d2 = s->secretflag[sSECNEXT];
12483
12484 large_dialog(secret_dlg,1.75);
12485
12486 for(int32_t q = 0; secret_dlg[q].proc != NULL; ++q)
12487 {
12488 if(secret_dlg[q].proc == jwin_frame_proc)
12489 secret_dlg[q].w = secret_dlg[q].h = 36;
12490 }
12491
12492 go();
12493
12494 if(do_zqdialog(secret_dlg,3) == 2)
12495 {
12496 saved = false;
12497 s->secretcombo[sBCANDLE] = secret_dlg[92].d1;
12498 s->secretcset[sBCANDLE] = secret_dlg[92].fg;
12499 s->secretflag[sBCANDLE] = secret_dlg[92].d2;
12500
12501 s->secretcombo[sRCANDLE] = secret_dlg[93].d1;
12502 s->secretcset[sRCANDLE] = secret_dlg[93].fg;
12503 s->secretflag[sRCANDLE] = secret_dlg[93].d2;
12504
12505 s->secretcombo[sWANDFIRE] = secret_dlg[94].d1;
12506 s->secretcset[sWANDFIRE] = secret_dlg[94].fg;
12507 s->secretflag[sWANDFIRE] = secret_dlg[94].d2;
12508
12509 s->secretcombo[sDIVINEFIRE] = secret_dlg[95].d1;
12510 s->secretcset[sDIVINEFIRE] = secret_dlg[95].fg;
12511 s->secretflag[sDIVINEFIRE] = secret_dlg[95].d2;
12512
12513 s->secretcombo[sARROW] = secret_dlg[96].d1;
12514 s->secretcset[sARROW] = secret_dlg[96].fg;
12515 s->secretflag[sARROW] = secret_dlg[96].d2;
12516
12517 s->secretcombo[sSARROW] = secret_dlg[97].d1;
12518 s->secretcset[sSARROW] = secret_dlg[97].fg;
12519 s->secretflag[sSARROW] = secret_dlg[97].d2;
12520
12521 s->secretcombo[sGARROW] = secret_dlg[98].d1;
12522 s->secretcset[sGARROW] = secret_dlg[98].fg;
12523 s->secretflag[sGARROW] = secret_dlg[98].d2;
12524
12525 s->secretcombo[sBOMB] = secret_dlg[99].d1;
12526 s->secretcset[sBOMB] = secret_dlg[99].fg;
12527 s->secretflag[sBOMB] = secret_dlg[99].d2;
12528
12529 s->secretcombo[sSBOMB] = secret_dlg[100].d1;
12530 s->secretcset[sSBOMB] = secret_dlg[100].fg;
12531 s->secretflag[sSBOMB] = secret_dlg[100].d2;
12532
12533 for(int32_t i=0; i<3; i++)
12534 {
12535 s->secretcombo[sBRANG+i] = secret_dlg[101+i].d1;
12536 s->secretcset[sBRANG+i] = secret_dlg[101+i].fg;
12537 s->secretflag[sBRANG+i] = secret_dlg[101+i].d2;
12538 }
12539
12540 for(int32_t i=0; i<2; i++)
12541 {
12542 s->secretcombo[sWANDMAGIC+i] = secret_dlg[104+i].d1;
12543 s->secretcset[sWANDMAGIC+i] = secret_dlg[104+i].fg;
12544 s->secretflag[sWANDMAGIC+i] = secret_dlg[104+i].d2;
12545 }
12546
12547 for(int32_t i=0; i<8; i++)
12548 {
12549 s->secretcombo[sSWORD+i] = secret_dlg[106+i].d1;
12550 s->secretcset[sSWORD+i] = secret_dlg[106+i].fg;
12551 s->secretflag[sSWORD+i] = secret_dlg[106+i].d2;
12552 }
12553
12554 s->secretcombo[sSTAIRS] = secret_dlg[114].d1;
12555 s->secretcset[sSTAIRS] = secret_dlg[114].fg;
12556 s->secretflag[sSTAIRS] = secret_dlg[114].d2;
12557
12558 s->secretcombo[sREFFIREBALL] = secret_dlg[115].d1;
12559 s->secretcset[sREFFIREBALL] = secret_dlg[115].fg;
12560 s->secretflag[sREFFIREBALL] = secret_dlg[115].d2;
12561
12562 for(int32_t i=0; i<4; i++)
12563 {
12564 s->secretcombo[sHOOKSHOT+i] = secret_dlg[116+i].d1;
12565 s->secretcset[sHOOKSHOT+i] = secret_dlg[116+i].fg;
12566 s->secretflag[sHOOKSHOT+i] = secret_dlg[116+i].d2;
12567 }
12568
12569 for(int32_t i=0; i<16; i++)
12570 {
12571 s->secretcombo[sSECRET01+i] = secret_dlg[120+i].d1;
12572 s->secretcset[sSECRET01+i] = secret_dlg[120+i].fg;
12573 s->secretflag[sSECRET01+i] = secret_dlg[120+i].d2;
12574 }
12575 s->secretflag[sSECNEXT] = secret_dlg[137].d2;
12576
12577 }
12578
12579 comeback();
12580 return D_O_K;
12581 }
12582
12583 static DIALOG under_dlg[] =
12584 {
12585 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
12586 { jwin_win_proc, 72, 60, 176+1,120+1,vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
12587 { jwin_text_proc, 115, 83, 20, 20, vc(14), vc(1), 0, 0, 0, 0, (void *) "Current", NULL, NULL },
12588 { d_comboframe_proc, 122, 92, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12589 { d_combo_proc, 124, 94, 16, 16, 0, 0, 0, D_NOCLICK, 0, 0, NULL, NULL, NULL },
12590 { jwin_text_proc, 184, 83, 20, 20, vc(14), vc(1), 0, 0, 0, 0, (void *) "New", NULL, NULL },
12591 { d_comboframe_proc, 182, 92, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12592 { d_combo_proc, 184, 94, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12593 { jwin_button_proc, 90, 124, 61, 21, vc(14), vc(1), 's', D_EXIT, 0, 0, (void *) "&Set", NULL, NULL },
12594 { jwin_button_proc, 170, 124, 61, 21, vc(14), vc(1), 'c', D_EXIT, 0, 0, (void *) "&Cancel", NULL, NULL },
12595 { jwin_button_proc, 90, 152, 61, 21, vc(14), vc(1), 'a', D_EXIT, 0, 0, (void *) "Set &All", NULL, NULL },
12596 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
12597 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12598 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
12599 };
12600
12601 int32_t onUnderCombo()
12602 {
12603 char titlebuf[64];
12604 sprintf(titlebuf, "Under Combo (Layer %d)", CurrentLayer);
12605 under_dlg[0].dp = titlebuf;
12606 under_dlg[0].dp2 = get_zc_font(font_lfont);
12607 mapscr* scr;
12608 if(CurrentLayer==0)
12609 {
12610 scr=Map.CurrScr();
12611 }
12612 else
12613 {
12614 auto map=Map.CurrScr()->layermap[CurrentLayer-1]-1;
12615 auto screen=Map.CurrScr()->layerscreen[CurrentLayer-1];
12616 scr = Map.AbsoluteScr(map,screen);
12617 }
12618 if(!scr) return D_O_K;
12619
12620 under_dlg[3].d1=scr->undercombo;
12621 under_dlg[3].fg=scr->undercset;
12622
12623 under_dlg[6].d1=Combo;
12624 under_dlg[6].fg=CSet;
12625
12626 large_dialog(under_dlg);
12627 // Doesn't place "New" and "Current" text too well
12628 under_dlg[1].x=342;
12629 under_dlg[4].x=438;
12630
12631 int32_t ret = do_zqdialog(under_dlg,-1);
12632
12633 if(ret==7)
12634 {
12635 saved=false;
12636 scr->undercombo = under_dlg[6].d1;
12637 scr->undercset = under_dlg[6].fg;
12638 }
12639
12640 if(ret==9 && jwin_alert("Confirm Overwrite","Set all Under Combos","on this map?",NULL,"&Yes","&No",'y','n',get_zc_font(font_lfont))==1)
12641 {
12642 saved=false;
12643
12644 for(int32_t i=0; i<128; i++)
12645 {
12646 Map.Scr(i)->undercombo = under_dlg[6].d1;
12647 Map.Scr(i)->undercset = under_dlg[6].fg;
12648 }
12649 }
12650
12651 return D_O_K;
12652 }
12653
12654 static DIALOG list_dlg[] =
12655 {
12656 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
12657 8 { jwin_win_proc, 60-12, 40, 200+24, 148, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
12658 8 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12659 8 { jwin_list_proc, 72-12-4, 60+4, 176+24+8, 92+3, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, NULL, NULL, NULL },
12660 8 { jwin_button_proc, 90, 163, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
12661 8 { jwin_button_proc, 170, 163, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
12662 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
12663 };
12664
12665 static DIALOG wlist_dlg[] =
12666 {
12667 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
12668 8 { jwin_win_proc, 60-12, 40, 200+24+24, 156, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
12669 8 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12670 8 { d_wlist_proc, 72-12-4, 60+4, 176+24+8, 92+3, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, NULL, NULL, NULL },
12671 8 { jwin_button_proc, 90, 171, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Edit", NULL, NULL },
12672 8 { jwin_button_proc, 170, 171, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Done", NULL, NULL },
12673 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
12674 };
12675
12676
12677 /*
12678 typedef struct item_struct {
12679 char *s;
12680 int32_t i;
12681 } item_struct;
12682 */
12683 item_struct bii[MAXITEMS+1];
12684 int32_t bii_cnt=-1;
12685
12686 void build_bii_list(bool usenone)
12687 {
12688 int32_t start=bii_cnt=0;
12689
12690 if(usenone)
12691 {
12692 bii[0].s = (char *)"(None)";
12693 bii[0].i = -2;
12694 bii_cnt=start=1;
12695 }
12696
12697 for(int32_t i=0; i<MAXITEMS; i++)
12698 {
12699 bii[bii_cnt].s = item_string[i];
12700 bii[bii_cnt].i = i;
12701 ++bii_cnt;
12702 }
12703
12704 for(int32_t i=start; i<bii_cnt-1; i++)
12705 {
12706 for(int32_t j=i+1; j<bii_cnt; j++)
12707 {
12708 if(stricmp(bii[i].s,bii[j].s)>0 && strcmp(bii[j].s,""))
12709 {
12710 zc_swap(bii[i],bii[j]);
12711 }
12712 }
12713 }
12714 }
12715
12716
12717 const char *itemlist(int32_t index, int32_t *list_size)
12718 {
12719 if(index<0)
12720 {
12721 *list_size = bii_cnt;
12722 return NULL;
12723 }
12724
12725 return bii[index].s;
12726 }
12727 const char *itemlist_num(int32_t index, int32_t *list_size)
12728 {
12729 if(index<0)
12730 {
12731 *list_size = bii_cnt;
12732 return NULL;
12733 }
12734 static char biin_buf[64+6];
12735 if(bii[index].i < 0)
12736 return bii[index].s;
12737 sprintf(biin_buf, "%s (%03d)", bii[index].s, bii[index].i);
12738 return biin_buf;
12739 }
12740
12741 // disable items on dmaps stuff
12742 int32_t DI[MAXITEMS];
12743 int32_t nDI;
12744
12745 void initDI(int32_t index)
12746 {
12747 int32_t j=0;
12748
12749 for(int32_t i=0; i<MAXITEMS; i++)
12750 {
12751 int32_t index1=bii[i].i; // true index of item in dmap's DI list
12752
12753 if(DMaps[index].disableditems[index1])
12754 {
12755 DI[j]=i;
12756 j++;
12757 }
12758 }
12759
12760 nDI=j;
12761
12762 for(int32_t i=j; i<MAXITEMS; i++) DI[j]=0;
12763
12764 return;
12765 }
12766
12767 void insertDI(int32_t id, int32_t index)
12768 {
12769 int32_t trueid=bii[id].i;
12770 DMaps[index].disableditems[trueid] |= 1; //bit set
12771 initDI(index);
12772 return;
12773 }
12774
12775 void deleteDI(int32_t id, int32_t index)
12776 {
12777 int32_t i=DI[id];
12778 int32_t trueid=bii[i].i;
12779 DMaps[index].disableditems[trueid] &= (~1); // bit clear
12780 initDI(index);
12781 return;
12782 }
12783
12784 const char *DIlist(int32_t index, int32_t *list_size)
12785 {
12786 if(index<0)
12787 {
12788 *list_size = nDI;
12789 return NULL;
12790 }
12791
12792 int32_t i=DI[index];
12793 return bii[i].s;
12794
12795 }
12796
12797 weapon_struct biw[MAXWPNS];
12798 int32_t biw_cnt=-1;
12799
12800 void build_biw_list()
12801 {
12802 int32_t start=biw_cnt=0;
12803
12804 for(int32_t i=start; i<MAXWPNS; i++)
12805 {
12806 biw[biw_cnt].s = (char *)weapon_string[i];
12807 biw[biw_cnt].i = i;
12808 ++biw_cnt;
12809 }
12810
12811 for(int32_t i=start; i<biw_cnt-1; i++)
12812 {
12813 for(int32_t j=i+1; j<biw_cnt; j++)
12814 if(stricmp(biw[i].s,biw[j].s)>0 && strcmp(biw[j].s,""))
12815 zc_swap(biw[i],biw[j]);
12816 }
12817 }
12818
12819 const char *weaponlist(int32_t index, int32_t *list_size)
12820 {
12821 if(index<0)
12822 {
12823 *list_size = biw_cnt;
12824 return NULL;
12825 }
12826
12827 return biw[index].s;
12828 }
12829 const char *weaponlist_num(int32_t index, int32_t *list_size)
12830 {
12831 if(index<0)
12832 {
12833 *list_size = biw_cnt;
12834 return NULL;
12835 }
12836 static char biwn_buf[64+6];
12837 if(biw[index].i < 0)
12838 return biw[index].s;
12839 sprintf(biwn_buf, "%s (%03d)", biw[index].s, biw[index].i);
12840 return biwn_buf;
12841 }
12842 int32_t writeoneweapon(PACKFILE *f, int32_t index)
12843 {
12844 dword section_version=V_WEAPONS;
12845 dword section_cversion=CV_WEAPONS;
12846 int32_t zversion = ZELDA_VERSION;
12847 int32_t zbuild = VERSION_BUILD;
12848 int32_t iid = biw[index].i;
12849 al_trace("Writing Weapon Sprite .zwpnspr file for weapon id: %d\n", iid);
12850
12851 //section version info
12852 if(!p_iputl(zversion,f))
12853 {
12854 return 0;
12855 }
12856 if(!p_iputl(zbuild,f))
12857 {
12858 return 0;
12859 }
12860 if(!p_iputw(section_version,f))
12861 {
12862 return 0;
12863 }
12864
12865 if(!p_iputw(section_cversion,f))
12866 {
12867 return 0;
12868 }
12869
12870 //weapon string
12871
12872 if(!pfwrite((char *)weapon_string[iid], 64, f))
12873 {
12874 return 0;
12875 }
12876
12877 if(!p_putc(wpnsbuf[iid].misc,f))
12878 {
12879 return 0;
12880 }
12881
12882 if(!p_putc(wpnsbuf[iid].csets,f))
12883 {
12884 return 0;
12885 }
12886
12887 if(!p_putc(wpnsbuf[iid].frames,f))
12888 {
12889 return 0;
12890 }
12891
12892 if(!p_putc(wpnsbuf[iid].speed,f))
12893 {
12894 return 0;
12895 }
12896
12897 if(!p_putc(wpnsbuf[iid].type,f))
12898 {
12899 return 0;
12900 }
12901
12902 if(!p_iputw(wpnsbuf[iid].script,f))
12903 {
12904 return 0;
12905 }
12906
12907 //2.55 starts here
12908 if(!p_iputl(wpnsbuf[iid].tile,f))
12909 {
12910 return 0;
12911 }
12912
12913 return 1;
12914 }
12915
12916
12917 int32_t readoneweapon(PACKFILE *f, int32_t index)
12918 {
12919 dword section_version = 0;
12920 dword section_cversion = 0;
12921 int32_t zversion = 0;
12922 int32_t zbuild = 0;
12923 wpndata tempwpnspr;
12924 memset(&tempwpnspr, 0, sizeof(wpndata));
12925
12926
12927 //char dmapstring[64]={0};
12928 //section version info
12929 if(!p_igetl(&zversion,f))
12930 {
12931 return 0;
12932 }
12933 if(!p_igetl(&zbuild,f))
12934 {
12935 return 0;
12936 }
12937 if(!p_igetw(&section_version,f))
12938 {
12939 return 0;
12940 }
12941 if(!p_igetw(&section_cversion,f))
12942 {
12943 return 0;
12944 }
12945 al_trace("readoneweapon section_version: %d\n", section_version);
12946 al_trace("readoneweapon section_cversion: %d\n", section_cversion);
12947
12948 if ( zversion > ZELDA_VERSION )
12949 {
12950 al_trace("Cannot read .zwpnspr packfile made in ZC version (%x) in this version of ZC (%x)\n", zversion, ZELDA_VERSION);
12951 return 0;
12952 }
12953
12954 else if ( ( section_version > V_WEAPONS ) || ( section_version == V_WEAPONS && section_cversion < CV_WEAPONS ) )
12955 {
12956 al_trace("Cannot read .zwpnspr packfile made using V_WEAPONS (%d) subversion (%d)\n", section_version, section_cversion);
12957 return 0;
12958
12959 }
12960 else
12961 {
12962 al_trace("Reading a .zwpnspr packfile made in ZC Version: %x, Build: %d\n", zversion, zbuild);
12963 }
12964
12965 char tmp_wpn_name[64];
12966 memset(tmp_wpn_name,0,64);
12967 if(!pfread(&tmp_wpn_name, 64, f))
12968 {
12969 return 0;
12970 }
12971
12972 word oldtile = 0;
12973 if(section_version < 8)
12974 if(!p_igetw(&oldtile,f))
12975 return 0;
12976
12977 if(!p_getc(&tempwpnspr.misc,f))
12978 {
12979 return 0;
12980 }
12981
12982 if(!p_getc(&tempwpnspr.csets,f))
12983 {
12984 return 0;
12985 }
12986
12987 if(!p_getc(&tempwpnspr.frames,f))
12988 {
12989 return 0;
12990 }
12991
12992 if(!p_getc(&tempwpnspr.speed,f))
12993 {
12994 return 0;
12995 }
12996
12997 if(!p_getc(&tempwpnspr.type,f))
12998 {
12999 return 0;
13000 }
13001
13002 if(!p_igetw(&tempwpnspr.script,f))
13003 {
13004 return 0;
13005 }
13006
13007 //2.55 starts here
13008 if ( zversion >= 0x255 )
13009 {
13010 if ( section_version >= 7 )
13011 {
13012 if(!p_igetl(&tempwpnspr.tile,f))
13013 {
13014 return 0;
13015 }
13016 }
13017 }
13018 if ( zversion < 0x255 )
13019 {
13020 tempwpnspr.tile = oldtile;
13021 }
13022 ::memcpy( &(wpnsbuf[biw[index].i]),&tempwpnspr, sizeof(wpndata));
13023 ::memcpy(weapon_string[biw[index].i], tmp_wpn_name, 64);
13024
13025 return 1;
13026 }
13027
13028
13029 static wpndata copiedSprite;
13030 static byte spritecopied = 0;
13031 char temp_weapon_string[64] = {0};
13032
13033 void paste_wsprite(int32_t index = -1)
13034 {
13035 if(index < 0) index = wlist_dlg[2].d1;
13036 if(unsigned(index)>255)
13037 return;
13038 if(!spritecopied)
13039 return;
13040 ::memcpy( &(wpnsbuf[biw[index].i]),&copiedSprite, sizeof(wpndata));
13041 ::memcpy(weapon_string[biw[index].i], temp_weapon_string, 64);
13042 wlist_dlg[2].flags|=D_DIRTY;
13043 saved=false;
13044 }
13045 void copy_wsprite(int32_t index = -1)
13046 {
13047 if(index < 0) index = wlist_dlg[2].d1;
13048 if(unsigned(index)>255)
13049 return;
13050 ::memcpy(&copiedSprite, &(wpnsbuf[biw[index].i]), sizeof(wpndata));
13051 memset(temp_weapon_string,0,64);
13052 ::memcpy(temp_weapon_string, weapon_string[biw[index].i], 64);
13053 spritecopied = 1;
13054 }
13055 void save_wsprite(int32_t index = -1)
13056 {
13057 if(index < 0) index = wlist_dlg[2].d1;
13058 if(unsigned(index)>255)
13059 return;
13060 if(!getname("Save ZWPNSPR(.zwpnspr)", "zwpnspr", NULL,datapath,false))
13061 return;
13062
13063 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
13064 if(!f) return;
13065 if (!writeoneweapon(f,index))
13066 {
13067 Z_error("Could not write to .zwpnspr packfile %s\n", temppath);
13068 InfoDialog("ZWpnSpr Error", "Could not save the specified sprite.").show();
13069 }
13070 pack_fclose(f);
13071 }
13072 void load_wsprite(int32_t index = -1)
13073 {
13074 if(index < 0) index = wlist_dlg[2].d1;
13075 if(unsigned(index)>255)
13076 return;
13077 if(!getname("Load ZWPNSPR(.zwpnspr)", "zwpnspr", NULL,datapath,false))
13078 return;
13079 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
13080 if(!f) return;
13081
13082 if (!readoneweapon(f,index))
13083 {
13084 Z_error("Could not read from .zwpnspr packfile %s\n", temppath);
13085 InfoDialog("ZWpnSpr Error", "Could not load the specified sprite.").show();
13086 }
13087
13088 pack_fclose(f);
13089 wlist_dlg[2].flags|=D_DIRTY;
13090 saved=false;
13091 }
13092 void wpnsprite_rclick_func(int32_t index, int32_t x, int32_t y)
13093 {
13094 if(((unsigned)index)>255)
13095 return;
13096 NewMenu rcmenu {
13097 { "&Copy", [&](){copy_wsprite(index);} },
13098 { "Paste", "&v", [&](){paste_wsprite(index);}, 0, !spritecopied },
13099 { "&Save", [&](){save_wsprite(index);} },
13100 { "&Load", [&](){load_wsprite(index);} },
13101 };
13102 rcmenu.pop(x, y);
13103 }
13104
13105
13106 int32_t select_weapon(const char *prompt,int32_t weapon)
13107 {
13108 if(biw_cnt==-1)
13109 build_biw_list();
13110
13111 int32_t index=0;
13112
13113 for(int32_t j=0; j<biw_cnt; j++)
13114 {
13115 if(biw[j].i == weapon)
13116 {
13117 index=j;
13118 }
13119 }
13120
13121 wlist_dlg[0].dp=(void *)prompt;
13122 wlist_dlg[0].dp2=get_zc_font(font_lfont);
13123 wlist_dlg[2].d1=index;
13124 ListData weapon_list(weaponlist_num, &font);
13125 wlist_dlg[2].dp=(void *) &weapon_list;
13126 wlist_dlg[2].dp3 = (void *)&wpnsprite_rclick_func;
13127 wlist_dlg[2].flags|=(D_USER<<1);
13128
13129 large_dialog(wlist_dlg);
13130
13131 int32_t ret=do_zqdialog(wlist_dlg,2);
13132
13133 if(ret==0||ret==4)
13134 {
13135 position_mouse_z(0);
13136 return -1;
13137 }
13138
13139 index = wlist_dlg[2].d1;
13140 position_mouse_z(0);
13141 return biw[index].i;
13142 }
13143
13144 static int32_t seldata_copy;
13145 static void (*seldata_paste_func)(int32_t, int32_t);
13146
13147 void seldata_rclick_func(int32_t index, int32_t x, int32_t y)
13148 {
13149 NewMenu rcmenu {
13150 { "&Copy", [&](){seldata_copy = index;} },
13151 { "Paste", "&v", [&]()
13152 {
13153 seldata_paste_func(seldata_copy, index);
13154 saved = false;
13155 }, 0, seldata_copy < 0 },
13156 };
13157 rcmenu.pop(x, y);
13158 }
13159
13160 int32_t select_data(const char *prompt,int32_t index,const char *(proc)(int32_t,int32_t*), FONT *title_font, void (*copyFunc)(int32_t, int32_t))
13161 {
13162 if(proc==NULL)
13163 return -1;
13164
13165 list_dlg[0].dp=(void *)prompt;
13166 list_dlg[0].dp2=title_font;
13167 list_dlg[2].d1=index;
13168 ListData select_list(proc, &font);
13169 list_dlg[2].dp=(void *) &select_list;
13170
13171 large_dialog(list_dlg);
13172
13173 seldata_copy=-1;
13174 seldata_paste_func=copyFunc;
13175 if(copyFunc)
13176 {
13177 list_dlg[2].flags|=D_USER<<1;
13178 list_dlg[2].dp3=(void*)seldata_rclick_func;
13179 }
13180 else
13181 {
13182 list_dlg[2].flags&=~(D_USER<<1);
13183 list_dlg[2].dp3=0;
13184 }
13185
13186 int32_t ret=do_zqdialog(list_dlg,2);
13187
13188 if(ret==0||ret==4)
13189 {
13190 position_mouse_z(0);
13191 return -1;
13192 }
13193
13194 return list_dlg[2].d1;
13195 }
13196
13197 int32_t select_data(const char *prompt,int32_t index,const char *(proc)(int32_t,int32_t*), const char *b1, const char *b2, FONT *title_font, void (*copyFunc)(int32_t, int32_t))
13198 {
13199 if(proc==NULL)
13200 return -1;
13201
13202 list_dlg[0].dp=(void *)prompt;
13203 list_dlg[0].dp2=title_font;
13204 list_dlg[2].d1=index;
13205 ListData select_data_list(proc, &font);
13206 list_dlg[2].dp=(void *) &select_data_list;
13207 list_dlg[3].dp=(void *)b1;
13208 list_dlg[4].dp=(void *)b2;
13209
13210 large_dialog(list_dlg);
13211
13212 seldata_copy=-1;
13213 seldata_paste_func=copyFunc;
13214 if(copyFunc)
13215 {
13216 list_dlg[2].flags|=D_USER<<1;
13217 list_dlg[2].dp3=(void*)seldata_rclick_func;
13218 }
13219 else
13220 {
13221 list_dlg[2].flags&=~(D_USER<<1);
13222 list_dlg[2].dp3=0;
13223 }
13224
13225 int32_t ret = do_zqdialog(list_dlg,2);
13226 list_dlg[3].dp=(void *) "OK";
13227 list_dlg[4].dp=(void *) "Cancel";
13228
13229 if(ret==0||ret==4)
13230 {
13231 position_mouse_z(0);
13232 return -1;
13233 }
13234
13235 position_mouse_z(0);
13236 return list_dlg[2].d1;
13237 }
13238
13239 static char sfx_str_buf[42];
13240
13241 const char *sfxlist(int32_t index, int32_t *list_size)
13242 {
13243 if(index>=0)
13244 {
13245 bound(index,0,WAV_COUNT-1);
13246 sprintf(sfx_str_buf,"%d: %s",index, index ? sfx_string[index] : "(None)");
13247 return sfx_str_buf;
13248 }
13249
13250 *list_size=WAV_COUNT;
13251 return NULL;
13252 }
13253
13254 8 static ListData sfx_list(sfxlist, &font);
13255
13256 const char *screenscriptdroplist(int32_t index, int32_t *list_size)
13257 {
13258 if(index<0)
13259 {
13260 *list_size = biscreens_cnt;
13261 return NULL;
13262 }
13263
13264 return biscreens[index].first.c_str();
13265 }
13266
13267 //droplist like the dialog proc, naming scheme for this stuff is awful...
13268 8 static ListData screenscript_list(screenscriptdroplist, &a4fonts[font_pfont]);
13269
13270 int32_t onScreenScript()
13271 {
13272 call_screendata_dialog(7);
13273 return D_O_K;
13274 }
13275
13276 int32_t onScrData()
13277 {
13278 restore_mouse();
13279 call_screendata_dialog();
13280 return D_O_K;
13281 }
13282
13283 const char *roomslist(int32_t index, int32_t *list_size)
13284 {
13285 if(index>=0)
13286 {
13287 if(index>=MAXROOMTYPES)
13288 index=MAXROOMTYPES-1;
13289
13290 return roomtype_string[index];
13291 }
13292
13293 *list_size=MAXROOMTYPES;
13294 return NULL;
13295 }
13296
13297 static char number_str_buf[MIDI_TRACK_BUFFER_SIZE];
13298 int32_t number_list_size=1;
13299 bool number_list_zero=false;
13300
13301 const char *numberlist(int32_t index, int32_t *list_size)
13302 {
13303 if(index>=0)
13304 {
13305 bound(index,0,number_list_size-1);
13306 sprintf(number_str_buf,"%d",index+(number_list_zero?0:1));
13307 return number_str_buf;
13308 }
13309
13310 *list_size=number_list_size;
13311 return NULL;
13312 }
13313
13314 static char dmap_str_buf[37];
13315 int32_t dmap_list_size=MAXDMAPS;
13316 bool dmap_list_zero=true;
13317
13318 const char *dmaplist(int32_t index, int32_t *list_size)
13319 {
13320 if(index>=0)
13321 {
13322 bound(index,0,dmap_list_size-1);
13323 sprintf(dmap_str_buf,"%3d-%s",index+(dmap_list_zero?0:1), DMaps[index].name);
13324 return dmap_str_buf;
13325 }
13326
13327 *list_size=dmap_list_size;
13328 return NULL;
13329 }
13330
13331 char *hexnumlist(int32_t index, int32_t *list_size)
13332 {
13333 if(index>=0)
13334 {
13335 bound(index,0,number_list_size-1);
13336 sprintf(number_str_buf,"%X",index+(number_list_zero?0:1));
13337 return number_str_buf;
13338 }
13339
13340 *list_size=number_list_size;
13341 return NULL;
13342 }
13343
13344 const char *maplist(int32_t index, int32_t *list_size)
13345 {
13346 if(index>=0)
13347 {
13348 bound(index,0,MAXMAPS-1);
13349 sprintf(number_str_buf,"%d",index+1);
13350 return number_str_buf;
13351 }
13352
13353 *list_size=MAXMAPS;
13354 return NULL;
13355 }
13356
13357 const char *gotomaplist(int32_t index, int32_t *list_size)
13358 {
13359 if(index>=0)
13360 {
13361 bound(index,0,map_count-1);
13362 sprintf(number_str_buf,"%d",index+1);
13363 return number_str_buf;
13364 }
13365
13366 *list_size = map_count;
13367 return NULL;
13368 }
13369
13370 const char *midilist(int32_t index, int32_t *list_size)
13371 {
13372 if(index>=0)
13373
13374 {
13375 bound(index,0,MAXCUSTOMMIDIS_ZQ-1);
13376 return midi_string[index];
13377 }
13378
13379 *list_size=MAXCUSTOMMIDIS_ZQ;
13380 return NULL;
13381 }
13382
13383 const char *custommidilist(int32_t index, int32_t *list_size)
13384 {
13385 if(index>=0)
13386 {
13387 bound(index,0,MAXCUSTOMMIDIS_ZQ-1);
13388 sprintf(number_str_buf,"%3d - %s",index+(number_list_zero?0:1),customtunes[index].data?customtunes[index].title:"(Empty)");
13389 return number_str_buf;
13390 }
13391
13392 *list_size=number_list_size;
13393 return NULL;
13394 }
13395
13396 const char *enhancedmusiclist(int32_t index, int32_t *list_size)
13397 {
13398 index=index; //this is here to prevent unused parameter warnings
13399 list_size=list_size; //this is here to prevent unused parameter warnings
13400 /*if(index>=0)
13401 {
13402 bound(index,0,MAXMUSIC-1);
13403 sprintf(number_str_buf,"%3d - %s",index+(number_list_zero?0:1),enhancedMusic[index].filename[0]?enhancedMusic[index].title:"(Empty)" );
13404 return number_str_buf;
13405 }
13406 *list_size=number_list_size;*/
13407 return NULL;
13408 }
13409
13410
13411 const char *levelnumlist(int32_t index, int32_t *list_size)
13412 {
13413 if(index>=0)
13414 {
13415 bound(index,0,0xFFF);
13416 sprintf(number_str_buf,"%.3X - %s",index,palnames[index]);
13417 return number_str_buf;
13418 }
13419
13420 *list_size=MAXLEVELS;
13421 return NULL;
13422 }
13423
13424 static char shop_str_buf[40];
13425 int32_t shop_list_size=1;
13426
13427 const char *shoplist(int32_t index, int32_t *list_size)
13428 {
13429 if(index>=0)
13430 {
13431 bound(index,0,shop_list_size-1);
13432 sprintf(shop_str_buf,"%3d: %s",index,QMisc.shop[index].name);
13433 return shop_str_buf;
13434 }
13435
13436 *list_size=shop_list_size;
13437 return NULL;
13438 }
13439
13440 static char bottle_str_buf[40];
13441 int32_t bottle_list_size=1;
13442
13443 const char *bottlelist(int32_t index, int32_t *list_size)
13444 {
13445 if(index>=0)
13446 {
13447 bound(index,0,bottle_list_size-1);
13448 sprintf(bottle_str_buf,"%2d: %s",index+1,QMisc.bottle_types[index].name);
13449 return bottle_str_buf;
13450 }
13451
13452 *list_size=bottle_list_size;
13453 return NULL;
13454 }
13455
13456 static char bottleshop_str_buf[40];
13457 int32_t bottleshop_list_size=1;
13458
13459 const char *bottleshoplist(int32_t index, int32_t *list_size)
13460 {
13461 if(index>=0)
13462 {
13463 bound(index,0,bottleshop_list_size-1);
13464 sprintf(bottleshop_str_buf,"%3d: %s",index,QMisc.bottle_shop_types[index].name);
13465 return bottleshop_str_buf;
13466 }
13467
13468 *list_size=bottleshop_list_size;
13469 return NULL;
13470 }
13471
13472 static char info_str_buf[40];
13473 int32_t info_list_size=1;
13474
13475 const char *infolist(int32_t index, int32_t *list_size)
13476 {
13477 if(index>=0)
13478 {
13479 bound(index,0,info_list_size-1);
13480 sprintf(info_str_buf,"%3d: %s",index,QMisc.info[index].name);
13481 return info_str_buf;
13482 }
13483
13484 *list_size=info_list_size;
13485 return NULL;
13486 }
13487
13488 bool mapcount_will_affect_layers(word newmapcount)
13489 {
13490 for(int32_t i=0; i<(newmapcount)*MAPSCRS; i++)
13491 {
13492 mapscr *layerchecker=&TheMaps[i];
13493
13494 for(int32_t j=0; j<6; j++)
13495 {
13496 if(layerchecker->layermap[j]>(newmapcount))
13497 {
13498 return true;
13499 }
13500 }
13501 }
13502 return false;
13503 }
13504
13505 void update_map_count(word newmapcount)
13506 {
13507 if(map_count == newmapcount) return;
13508 saved = false;
13509 setMapCount2(newmapcount);
13510 //Prevent the nine 'last mapscreen' buttons from pointing to invlid locations
13511 //if the user reduces the mapcount. -Z ( 23rd September, 2019 )
13512 for ( int32_t q = 0; q < 9; q++ )
13513 {
13514 map_page[q].map = ( map_page[q].map > newmapcount-1 ) ? newmapcount-1 : map_page[q].map;
13515 }
13516 for(int32_t i=0; i<(newmapcount)*MAPSCRS; i++)
13517 {
13518 fix_layers(&TheMaps[i], false);
13519 }
13520
13521 refresh(rMAP+rSCRMAP+rMENU);
13522 }
13523
13524 int32_t onGotoMap()
13525 {
13526 int32_t ret = select_data("Goto Map",Map.getCurrMap(),gotomaplist,get_zc_font(font_lfont));
13527
13528 if(ret >= 0)
13529 {
13530 int32_t m=Map.getCurrMap();
13531 Map.setCurrMap(ret);
13532
13533 if(m!=Map.getCurrMap())
13534 {
13535 reset_relational_tile_grid();
13536 }
13537 }
13538
13539 refresh(rALL);
13540 return D_O_K;
13541 }
13542
13543 int32_t onFlags()
13544 {
13545 restore_mouse();
13546 int32_t ret=select_cflag("Select Combo Flag",Flag);
13547 position_mouse_z(0);
13548
13549 if(ret>=0)
13550 {
13551 Flag=ret;
13552 refresh(rMENU);
13553 doflags();
13554 }
13555
13556 return D_O_K;
13557 }
13558
13559 static DIALOG usedcombo_list_dlg[] =
13560 {
13561 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
13562 8 { jwin_win_proc, 60-12, 40, 200+24, 148, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Combos Used", NULL, NULL },
13563 8 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
13564 8 { jwin_textbox_proc, 72-12, 60+4, 176+24+1, 92+4, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, NULL, NULL, NULL },
13565 8 { jwin_button_proc, 130, 163, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
13566 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
13567 };
13568
13569
13570
13571 int32_t onUsedCombos()
13572 {
13573 restore_mouse();
13574 usedcombo_list_dlg[0].dp2=get_zc_font(font_lfont);
13575
13576 int32_t usedcombos[7][300][2];
13577 char combolist_text[65536];
13578 char temptext[80];
13579
13580 int32_t drawmap=Map.getCurrMap();
13581 int32_t drawscr=Map.getCurrScr();
13582 int32_t counter[7];
13583
13584 for(int32_t layer=0; layer<7; ++layer)
13585 {
13586 counter[layer]=0;
13587
13588 if(layer==0)
13589 {
13590 drawmap=Map.getCurrMap();
13591 drawscr=Map.getCurrScr();
13592 }
13593 else
13594 {
13595 drawmap=Map.CurrScr()->layermap[layer-1]-1;
13596 drawscr=Map.CurrScr()->layerscreen[layer-1];
13597 }
13598 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
13599 if(!draw_mapscr) continue;
13600
13601 usedcombos[layer][0][0]=draw_mapscr->data[0];
13602 usedcombos[layer][0][1]=1;
13603 counter[layer]=1;
13604
13605 for(int32_t i=1; i<176; ++i)
13606 {
13607 bool used=false;
13608
13609 for(int32_t j=0; j<counter[layer]; ++j)
13610 {
13611 if(usedcombos[layer][j][0]==draw_mapscr->data[i])
13612 {
13613 ++usedcombos[layer][j][1];
13614 used=true;
13615 break;
13616 }
13617 }
13618
13619 if(!used)
13620 {
13621 usedcombos[layer][counter[layer]][0]=draw_mapscr->data[i];
13622 usedcombos[layer][counter[layer]][1]=1;
13623 ++counter[layer];
13624 }
13625 }
13626
13627 for(int32_t i=0; i<counter[layer]-1; i++)
13628 {
13629 for(int32_t j=i+1; j<counter[layer]; j++)
13630 {
13631 if(usedcombos[layer][i][0]>usedcombos[layer][j][0])
13632 {
13633 zc_swap(usedcombos[layer][i][0],usedcombos[layer][j][0]);
13634 zc_swap(usedcombos[layer][i][1],usedcombos[layer][j][1]);
13635 }
13636 }
13637 }
13638 }
13639
13640 sprintf(combolist_text, " ");
13641
13642 for(int32_t layer=0; layer<7; ++layer)
13643 {
13644 if(counter[layer]>0)
13645 {
13646 if(layer>0)
13647 {
13648 strcat(combolist_text, "\n");
13649 }
13650
13651 sprintf(temptext, "Combos on layer %d\n-----------------\n", layer);
13652 strcat(combolist_text, temptext);
13653
13654 for(int32_t i=0; i<counter[layer]; i++)
13655 {
13656 if((i<counter[layer]-1) && (((usedcombos[layer][i][1]==usedcombos[layer][i+1][1]&&(usedcombos[layer][i][0]+1==usedcombos[layer][i+1][0])) && ((i==0) || ((usedcombos[layer][i][1]!=usedcombos[layer][i-1][1])||((usedcombos[layer][i][0]-1!=usedcombos[layer][i-1][0])))))))
13657 {
13658 sprintf(temptext, "%5d ", usedcombos[layer][i][0]);
13659 strcat(combolist_text, temptext);
13660 }
13661 else if(((i>0) && (((usedcombos[layer][i][1]==usedcombos[layer][i-1][1])&&((usedcombos[layer][i][0]-1==usedcombos[layer][i-1][0]))) && ((i==counter[layer]-1) || ((usedcombos[layer][i][1]!=usedcombos[layer][i+1][1])||((usedcombos[layer][i][0]+1!=usedcombos[layer][i+1][0])))))))
13662 {
13663 sprintf(temptext, "- %5d (%3d)\n", usedcombos[layer][i][0],usedcombos[layer][i][1]);
13664 strcat(combolist_text, temptext);
13665 }
13666 else if(((i==0) && ((usedcombos[layer][i][1]!=usedcombos[layer][i+1][1])||((usedcombos[layer][i][0]+1!=usedcombos[layer][i+1][0]))))||
13667 ((i==counter[layer]-1) && ((usedcombos[layer][i][1]!=usedcombos[layer][i-1][1])||((usedcombos[layer][i][0]-1!=usedcombos[layer][i-1][0]))))||
13668 ((i>0) && (i<counter[layer]-1) && ((usedcombos[layer][i][1]!=usedcombos[layer][i+1][1])||((usedcombos[layer][i][0]+1!=usedcombos[layer][i+1][0]))) && ((usedcombos[layer][i][1]!=usedcombos[layer][i-1][1])||((usedcombos[layer][i][0]-1!=usedcombos[layer][i-1][0])))))
13669 {
13670 sprintf(temptext, " %5d (%3d)\n", usedcombos[layer][i][0],usedcombos[layer][i][1]);
13671 strcat(combolist_text, temptext);
13672 }
13673 }
13674 }
13675 }
13676
13677 strcat(combolist_text, "\n");
13678 usedcombo_list_dlg[2].dp=combolist_text;
13679 usedcombo_list_dlg[2].d2=0;
13680
13681 large_dialog(usedcombo_list_dlg);
13682
13683 do_zqdialog(usedcombo_list_dlg,2);
13684 position_mouse_z(0);
13685 return D_O_K;
13686 }
13687
13688 int32_t onItem()
13689 {
13690 restore_mouse();
13691 int32_t exit_status;
13692 int32_t current_item=Map.CurrScr()->hasitem != 0 ? Map.CurrScr()->item : -1;
13693
13694 ItemListerDialog(current_item,true).show();
13695 if(current_item != lister_sel_val)
13696 {
13697 if(lister_sel_val>=0)
13698 {
13699 saved = false;
13700 Map.CurrScr()->item = lister_sel_val;
13701 Map.CurrScr()->hasitem = true;
13702 }
13703 else
13704 {
13705 saved = false;
13706 Map.CurrScr()->hasitem = false;
13707 }
13708 }
13709
13710 refresh(rMAP+rMENU);
13711 return D_O_K;
13712 }
13713
13714 void call_room_dlg(mapscr* scr);
13715 int32_t onRoom()
13716 {
13717 restore_mouse();
13718 auto* scr = Map.CurrScr();
13719 call_room_dlg(scr);
13720
13721 refresh(rMAP+rMENU);
13722 return D_O_K;
13723 }
13724
13725 int32_t onEndString()
13726 {
13727 int32_t ret=select_data("Select Ending String",QMisc.endstring,msgslist,get_zc_font(font_lfont));
13728
13729 if(ret>=0)
13730 {
13731 saved=false;
13732 QMisc.endstring=msglistcache[ret];
13733 }
13734
13735 refresh(rMENU);
13736 return D_O_K;
13737 }
13738
13739 8 static ListData levelnum_list(levelnumlist, &font);
13740
13741 static DIALOG screen_pal_dlg[] =
13742 {
13743 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
13744 8 { jwin_win_proc, 60-12, 40, 200-16, 96, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Select Palette", NULL, NULL },
13745 8 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
13746 8 { jwin_droplist_proc, 72-12, 84+4, 161, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &levelnum_list, NULL, NULL },
13747 8 { jwin_button_proc, 70, 111, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
13748 8 { jwin_button_proc, 150, 111, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
13749 8 { jwin_text_proc, 72-12, 60+4, 168, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Note: This does not affect how the", NULL, NULL },
13750 8 { jwin_text_proc, 72-12, 72+4, 168, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "room will be displayed in-game!", NULL, NULL },
13751 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
13752 };
13753 // return list_dlg[2].d1;
13754
13755 int32_t onScreenPalette()
13756 {
13757 restore_mouse();
13758 screen_pal_dlg[0].dp2=get_zc_font(font_lfont);
13759 auto oldcol = screen_pal_dlg[2].d1 = Map.getcolor();
13760
13761 large_dialog(screen_pal_dlg);
13762 auto old_valid = Map.CurrScr()->valid;
13763 pause_dlg_tint(true);
13764 zq_set_screen_never_freeze(true);
13765 while(true)
13766 {
13767 auto ret = do_zqdialog(screen_pal_dlg,2);
13768 if(ret == 2)
13769 {
13770 Map.setcolor(screen_pal_dlg[2].d1);
13771 refresh(rALL);
13772 }
13773 else
13774 {
13775 if(ret == 3)
13776 {
13777 if(screen_pal_dlg[2].d1 != oldcol)
13778 saved=false;
13779 Map.setcolor(screen_pal_dlg[2].d1);
13780 }
13781 else
13782 {
13783 Map.setcolor(oldcol);
13784 Map.CurrScr()->valid = old_valid;
13785 }
13786 refresh(rALL);
13787 break;
13788 }
13789 }
13790 pause_dlg_tint(false);
13791 zq_set_screen_never_freeze(false);
13792
13793 rebuild_trans_table();
13794
13795 return D_O_K;
13796 }
13797
13798 int32_t onDecScrPal()
13799 {
13800 if(DisableLPalShortcuts)
13801 {
13802 lpal_dsa();
13803 return D_O_K;
13804 }
13805 restore_mouse();
13806 int32_t c=Map.getcolor();
13807 c+=511;
13808 c=c%512;
13809 Map.setcolor(c);
13810 refresh(rALL);
13811 saved = false;
13812 return D_O_K;
13813 }
13814
13815 int32_t onIncScrPal()
13816 {
13817 if(DisableLPalShortcuts)
13818 {
13819 lpal_dsa();
13820 return D_O_K;
13821 }
13822 restore_mouse();
13823 int32_t c=Map.getcolor();
13824 c+=1;
13825 c=c%512;
13826 Map.setcolor(c);
13827 refresh(rALL);
13828 saved = false;
13829 return D_O_K;
13830 }
13831
13832 int32_t PalWrap(int32_t kX, int32_t const kLowerBound, int32_t const kUpperBound)
13833 {
13834 int32_t range_size = kUpperBound - kLowerBound + 1;
13835
13836 if (kX < kLowerBound)
13837 kX += range_size * ((kLowerBound - kX) / range_size + 1);
13838
13839 return kLowerBound + (kX - kLowerBound) % range_size;
13840 }
13841
13842 int32_t onDecScrPal16()
13843 {
13844 if(DisableLPalShortcuts)
13845 {
13846 lpal_dsa();
13847 return D_O_K;
13848 }
13849 restore_mouse();
13850 int32_t c=Map.getcolor();
13851
13852 c = PalWrap( ( c-0x10 ), 0, 511 );
13853
13854 Map.setcolor(c);
13855 refresh(rALL);
13856 saved = false;
13857 return D_O_K;
13858 }
13859
13860 int32_t onIncScrPal16()
13861 {
13862 if(DisableLPalShortcuts)
13863 {
13864 lpal_dsa();
13865 return D_O_K;
13866 }
13867 restore_mouse();
13868 int32_t c=Map.getcolor();
13869
13870 c = PalWrap( ( c+0x10 ), 0, 511 );
13871 Map.setcolor(c);
13872 refresh(rALL);
13873 saved = false;
13874 return D_O_K;
13875 }
13876
13877 int32_t d_ndroplist_proc(int32_t msg,DIALOG *d,int32_t c)
13878 {
13879 int32_t ret = jwin_droplist_proc(msg,d,c);
13880
13881 // The only place this proc is used is in the info type editor.
13882 // If it's ever used anywhere else, this will probably need to be changed.
13883 // Maybe add a flag for it or something.
13884 int32_t msgID=msg_at_pos(d->d1);
13885
13886 switch(msg)
13887 {
13888 case MSG_DRAW:
13889 case MSG_CHAR:
13890 case MSG_CLICK:
13891 textprintf_ex(screen,font,d->x - 48,d->y + 4,jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%5d",msgID);
13892 }
13893
13894 return ret;
13895 }
13896
13897 int32_t d_idroplist_proc(int32_t msg,DIALOG *d,int32_t c)
13898 {
13899 int32_t ret = jwin_droplist_proc(msg,d,c);
13900
13901 switch(msg)
13902 {
13903 case MSG_DRAW:
13904 case MSG_CHAR:
13905 case MSG_CLICK:
13906 int32_t tile = bii[d->d1].i >=0 ? itemsbuf[bii[d->d1].i].tile : 0;
13907 int32_t cset = bii[d->d1].i >=0 ? itemsbuf[bii[d->d1].i].csets&15 : 0;
13908 int32_t x = d->x + d->w + 4;
13909 int32_t y = d->y - 8;
13910 int32_t w = 32;
13911 int32_t h = 32;
13912
13913 BITMAP *buf = create_bitmap_ex(8,16,16);
13914 BITMAP *bigbmp = create_bitmap_ex(8,w,h);
13915
13916 if(buf && bigbmp)
13917 {
13918 clear_bitmap(buf);
13919
13920 if(tile)
13921 overtile16(buf, tile,0,0,cset,0);
13922
13923 stretch_blit(buf, bigbmp, 0,0, 16, 16, 0, 0, w, h);
13924 destroy_bitmap(buf);
13925 jwin_draw_frame(screen,x,y,w+4,h+4,FR_DEEP);
13926 blit(bigbmp,screen,0,0,x+2,y+2,w,h);
13927 destroy_bitmap(bigbmp);
13928 }
13929
13930 }
13931
13932 return ret;
13933 }
13934
13935 int32_t d_nidroplist_proc(int32_t msg,DIALOG *d,int32_t c)
13936 {
13937 int32_t ret = d_idroplist_proc(msg,d,c);
13938
13939 switch(msg)
13940 {
13941 case MSG_DRAW:
13942 case MSG_CHAR:
13943 case MSG_CLICK:
13944 textprintf_ex(screen,font,d->x - 48,d->y + 4,jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%5d",bii[d->d1].i);
13945 }
13946
13947 return ret;
13948 }
13949
13950 int32_t d_wlist_proc(int32_t msg,DIALOG *d,int32_t c)
13951 {
13952 if(msg == MSG_XCHAR)
13953 {
13954 if(key_shifts & KB_CTRL_FLAG) //CTRL overrides the lister search function
13955 {
13956 int32_t ret = D_USED_CHAR;
13957 switch(c>>8)
13958 {
13959 case KEY_V:
13960 paste_wsprite();
13961 break;
13962 case KEY_C:
13963 copy_wsprite();
13964 break;
13965 case KEY_S:
13966 save_wsprite();
13967 break;
13968 case KEY_L:
13969 load_wsprite();
13970 break;
13971 default: ret = 0;
13972 }
13973 if(ret) return ret;
13974 }
13975 }
13976 int32_t ret = jwin_abclist_proc(msg,d,c);
13977
13978 switch(msg)
13979 {
13980 case MSG_DRAW:
13981 case MSG_CHAR:
13982 case MSG_CLICK:
13983
13984 int32_t tile = 0;
13985 int32_t cset = 0;
13986 tile= wpnsbuf[biw[d->d1].i].tile;
13987 cset= wpnsbuf[biw[d->d1].i].csets&15;
13988 int32_t x = d->x + d->w + 4;
13989 int32_t y = d->y;
13990 int32_t w = 32;
13991 int32_t h = 32;
13992 float temp_scale = 2;
13993
13994 BITMAP *buf = create_bitmap_ex(8,16,16);
13995 BITMAP *bigbmp = create_bitmap_ex(8,w,h);
13996
13997 if(buf && bigbmp)
13998 {
13999 clear_bitmap(buf);
14000
14001 if(tile)
14002 overtile16(buf, tile,0,0,cset,0);
14003
14004 stretch_blit(buf, bigbmp, 0,0, 16, 16, 0, 0, w, h);
14005 destroy_bitmap(buf);
14006 jwin_draw_frame(screen,x,y,w+4,h+4,FR_DEEP);
14007 blit(bigbmp,screen,0,0,x+2,y+2,w,h);
14008 destroy_bitmap(bigbmp);
14009 }
14010
14011 //Display the sprite ID.
14012 if (biw[d->d1].i >= 0)
14013 {
14014 textprintf_ex(screen, font, x, y + (20 * temp_scale), jwin_pal[jcTEXTFG], jwin_pal[jcBOX], "#%d ", biw[d->d1].i);
14015 }
14016
14017 }
14018
14019 return ret;
14020 }
14021
14022
14023 /**********************************/
14024 // Triforce Pieces //
14025 /**********************************/
14026
14027 static byte triframe_points[9*4] =
14028 {
14029 0,2,2,0, 2,0,4,2, 0,2,4,2, 1,1,3,1, 2,0,2,2,
14030 1,1,1,2, 1,1,2,2, 3,1,3,2, 3,1,2,2
14031 };
14032
14033 int32_t d_tri_frame_proc(int32_t msg,DIALOG *d,int32_t c)
14034 {
14035 //these are here to bypass compiler warnings about unused arguments
14036 c=c;
14037
14038 if(msg==MSG_DRAW)
14039 {
14040 int32_t x[5],y[3];
14041
14042 x[0]=d->x;
14043 x[1]=d->x+(d->w>>2);
14044 x[2]=d->x+(d->w>>1);
14045 x[3]=d->x+(d->w>>1)+(d->w>>2);
14046 x[4]=d->x+d->w;
14047 y[0]=d->y;
14048 y[1]=d->y+(d->h>>1);
14049 y[2]=d->y+d->h;
14050
14051 byte *p = triframe_points;
14052
14053 for(int32_t i=0; i<9; i++)
14054 {
14055 line(screen,x[*p],y[*(p+1)],x[*(p+2)],y[*(p+3)],d->fg);
14056 p+=4;
14057 }
14058 }
14059
14060 return D_O_K;
14061 }
14062
14063 int32_t d_tri_edit_proc(int32_t msg,DIALOG *d,int32_t c)
14064 {
14065 jwin_button_proc(msg,d,c);
14066
14067 if(msg==MSG_CLICK)
14068 {
14069 int32_t v = getnumber("Piece Number",d->d1);
14070
14071 if(v>=0)
14072 {
14073 bound(v,1,8);
14074
14075 if(v!=d->d1)
14076 {
14077 DIALOG *tp = d - d->d2;
14078
14079 for(int32_t i=0; i<8; i++)
14080 {
14081 if(tp->d1==v)
14082 {
14083 tp->d1 = d->d1;
14084 ((char*)(tp->dp))[0] = d->d1+'0';
14085 jwin_button_proc(MSG_DRAW,tp,0);
14086 }
14087
14088 ++tp;
14089 }
14090
14091 d->d1 = v;
14092 ((char*)(d->dp))[0] = v+'0';
14093 }
14094 }
14095
14096 d->flags = 0;
14097 jwin_button_proc(MSG_DRAW,d,0);
14098 }
14099
14100 return D_O_K;
14101 }
14102
14103 static DIALOG tp_dlg[] =
14104 {
14105 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
14106 8 { jwin_win_proc, 56, 32, 208, 160, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
14107 8 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
14108 8 { d_tri_frame_proc, 64, 56, 192, 96, jwin_pal[jcBOXFG], jwin_pal[jcBOX], 0, 0, 0, 0, NULL, NULL, NULL },
14109 // 3
14110 8 { d_tri_edit_proc, 138, 82, 17, 17, vc(14), vc(1), 0, 0, 0, 0, (void *) "1", NULL, NULL },
14111 8 { d_tri_edit_proc, 166, 82, 17, 17, vc(14), vc(1), 0, 0, 0, 1, (void *) "2", NULL, NULL },
14112 8 { d_tri_edit_proc, 90, 130, 17, 17, vc(14), vc(1), 0, 0, 0, 2, (void *) "3", NULL, NULL },
14113 8 { d_tri_edit_proc, 214, 130, 17, 17, vc(14), vc(1), 0, 0, 0, 3, (void *) "4", NULL, NULL },
14114 // 7
14115 8 { d_tri_edit_proc, 138, 110, 17, 17, vc(14), vc(1), 0, 0, 0, 4, (void *) "5", NULL, NULL },
14116 8 { d_tri_edit_proc, 118, 130, 17, 17, vc(14), vc(1), 0, 0, 0, 5, (void *) "6", NULL, NULL },
14117 8 { d_tri_edit_proc, 166, 110, 17, 17, vc(14), vc(1), 0, 0, 0, 6, (void *) "7", NULL, NULL },
14118 8 { d_tri_edit_proc, 186, 130, 17, 17, vc(14), vc(1), 0, 0, 0, 7, (void *) "8", NULL, NULL },
14119 // 11
14120 8 { jwin_button_proc, 90, 166, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
14121 8 { jwin_button_proc, 170, 166, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
14122 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
14123 };
14124
14125 int32_t onTriPieces()
14126 {
14127 tp_dlg[0].dp2=get_zc_font(font_lfont);
14128 char temptext[8][2];
14129
14130 for(int32_t i=0; i<8; i++)
14131 {
14132 tp_dlg[i+3].d1 = QMisc.triforce[i];
14133 // ((char*)(tp_dlg[i+3].dp))[0] = QMisc.triforce[i]+'0';
14134 sprintf(temptext[i], "%d", QMisc.triforce[i]);
14135 tp_dlg[i+3].dp=temptext[i];
14136 }
14137
14138 large_dialog(tp_dlg);
14139
14140 if(do_zqdialog(tp_dlg,-1) == 11)
14141 {
14142 saved=false;
14143
14144 for(int32_t i=0; i<8; i++)
14145 QMisc.triforce[i] = tp_dlg[i+3].d1;
14146 }
14147
14148 return D_O_K;
14149 }
14150
14151
14152 /**********************************/
14153 /*********** onDMaps ************/
14154 /**********************************/
14155
14156 int32_t d_maptile_proc(int32_t msg,DIALOG *d,int32_t c);
14157 bool small_dmap=false;
14158
14159 static DIALOG dmapmaps_dlg[] =
14160 {
14161
14162 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
14163 { jwin_win_proc, 4, 18, 313, 217, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Custom DMap Map Styles", NULL, NULL },
14164 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
14165 { jwin_button_proc, 93, 208, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
14166 { jwin_button_proc, 168, 208, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
14167 { d_ctext2_proc, 160, 38, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Minimaps", NULL, NULL },
14168 { d_ctext2_proc, 112, 46, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Without Map", NULL, NULL },
14169 { d_ctext2_proc, 208, 46, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "With Map", NULL, NULL },
14170
14171 { d_ctext2_proc, 162, 110, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Large Maps", NULL, NULL },
14172 { d_ctext2_proc, 80, 118, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Without Map", NULL, NULL },
14173 { d_ctext2_proc, 240, 118, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "With Map", NULL, NULL },
14174 // 5
14175 { d_maptile_proc, 72, 54, 80, 48, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
14176 { d_maptile_proc, 168, 54, 80, 48, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
14177 { d_maptile_proc, 8, 126, 144, 80, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
14178 { d_maptile_proc, 168, 126, 144, 80, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
14179 // 11
14180 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
14181 };
14182
14183 int32_t d_hexedit_proc(int32_t msg,DIALOG *d,int32_t c)
14184 {
14185 return jwin_hexedit_proc(msg,d,c);
14186 }
14187
14188 void drawgrid(BITMAP *dest,int32_t x,int32_t y,int32_t grid,int32_t fg,int32_t bg,int32_t div)
14189 {
14190 if(div!=-1)
14191 rectfill(dest,x-1,y-1,x+63,y+3,div);
14192
14193 for(int32_t dx=0; dx<64; dx+=8)
14194 {
14195 if(grid&0x80)
14196 rectfill(dest,x+dx,y,x+dx+6,y+2,fg);
14197 else if(bg!=-1)
14198 rectfill(dest,x+dx,y,x+dx+6,y+2,bg);
14199
14200 grid<<=1;
14201 }
14202 }
14203
14204 void drawovergrid(BITMAP *dest,int32_t x,int32_t y,int32_t grid,int32_t color,int32_t div)
14205 {
14206 if(div!=-1)
14207 rectfill(dest,x-1,y-1,x+63,y+3,div);
14208
14209 for(int32_t dx=0; dx<64; dx+=4)
14210 {
14211 rectfill(dest,x+dx,y,x+dx+2,y+2,color);
14212 grid<<=1;
14213 }
14214 }
14215
14216 void drawgrid(BITMAP *dest,int32_t x,int32_t y,int32_t w, int32_t h, int32_t tw, int32_t th, int32_t *grid,int32_t fg,int32_t bg,int32_t div)
14217 {
14218 //these are here to bypass compiler warnings about unused arguments
14219 w=w;
14220 tw=tw;
14221 th=th;
14222
14223 rectfill(dest,x,y,x+(8*8),y+(1*4),div);
14224
14225 for(int32_t dy=0; dy<h; dy++)
14226 {
14227 for(int32_t dx=0; dx<64; dx+=8)
14228 {
14229 if(grid[0]&0x80)
14230 rectfill(dest,x+dx,y,x+dx+6,y+2,fg);
14231 else
14232 rectfill(dest,x+dx,y,x+dx+6,y+2,bg);
14233
14234 grid[0]<<=1;
14235 }
14236 }
14237 }
14238
14239 void drawgrid_s(BITMAP *dest,int32_t x,int32_t y,int32_t grid,int32_t fg,int32_t bg,int32_t div)
14240 {
14241 rectfill(dest,x-1,y-1,x+63,y+3,div);
14242
14243 for(int32_t dx=0; dx<64; dx+=8)
14244 {
14245 rectfill(dest,x+dx,y,x+dx+6,y+2,bg);
14246
14247 if(grid&0x80)
14248 rectfill(dest,x+dx+2,y,x+dx+4,y+2,fg);
14249
14250 grid<<=1;
14251 }
14252 }
14253
14254 void drawdmap(int32_t dmap)
14255 {
14256 int32_t c;
14257 zcolors mc=QMisc.colors;
14258
14259 switch((DMaps[dmap].type&dmfTYPE))
14260 {
14261 case dmDNGN:
14262 case dmCAVE:
14263 clear_bitmap(dmapbmp_small);
14264
14265 if(DMaps[dmap].minimap_2_tile)
14266 ;
14267 // overworld_map_tile overrides the NES minimap. dungeon_map_tile does not.
14268 else for(int32_t y=1; y<33; y+=4)
14269 drawgrid(dmapbmp_small,0,y,DMaps[dmap].grid[y>>2], DMaps[dmap].flags&dmfMINIMAPCOLORFIX ? mc.cave_fg : mc.dngn_fg, -1, -1);
14270
14271 c=DMaps[dmap].compass;
14272 // rectfill(dmapbmp,(c&15)*8+3,(c>>4)*4+1,(c&15)*8+5,(c>>4)*4+3,dvc(2*4));
14273 rectfill(dmapbmp_small,(c&15)*8+3,(c>>4)*4+1,(c&15)*8+5,(c>>4)*4+3,vc(4));
14274 c=DMaps[dmap].cont;
14275 rectfill(dmapbmp_small,(c&15)*8+3,(c>>4)*4+1,(c&15)*8+5,(c>>4)*4+3,vc(10));
14276 break;
14277
14278 case dmOVERW:
14279 clear_bitmap(dmapbmp_small);
14280
14281 if(DMaps[dmap].minimap_2_tile)
14282 ;
14283 else if(!mc.overworld_map_tile)
14284 for(int32_t y=1; y<33; y+=4)
14285 drawovergrid(dmapbmp_small,1,y,DMaps[dmap].grid[y>>2],mc.overw_bg,vc(0));
14286
14287 c=DMaps[dmap].cont;
14288 rectfill(dmapbmp_small,(c&15)*4+1,(c>>4)*4+1,(c&15)*4+3,(c>>4)*4+3,vc(10));
14289 break;
14290
14291 case dmBSOVERW:
14292 clear_bitmap(dmapbmp_small);
14293
14294 if(DMaps[dmap].minimap_2_tile)
14295 ;
14296 else if(!mc.overworld_map_tile)
14297 for(int32_t y=1; y<33; y+=4)
14298 // drawgrid_s(dmapbmp,1,y,DMaps[dmap].grid[y>>2],dvc(2*4),dvc(2*3),dvc(3+4));
14299 drawgrid_s(dmapbmp_small,0,y,DMaps[dmap].grid[y>>2],mc.bs_goal,mc.bs_dk,vc(14));
14300
14301 c=DMaps[dmap].cont;
14302 rectfill(dmapbmp_small,(c&15)*8+3,(c>>4)*4+1,(c&15)*8+5,(c>>4)*4+3,vc(10));
14303 break;
14304 }
14305 }
14306
14307 void drawdmap_screen(int32_t x, int32_t y, int32_t w, int32_t h, int32_t dmap)
14308 {
14309 BITMAP *tempbmp = create_bitmap_ex(8,w,h);
14310 clear_to_color(tempbmp, vc(0));
14311 zcolors mc=QMisc.colors;
14312
14313 // rectfill(tempbmp,x,y,x+w-1,y+h-1,vc(0));
14314
14315 if(DMaps[dmap].minimap_2_tile)
14316 {
14317 draw_block(tempbmp,0,0,DMaps[dmap].minimap_2_tile,DMaps[dmap].minimap_2_cset,5,3);
14318 }
14319 else if(((DMaps[dmap].type&dmfTYPE)==dmDNGN || (DMaps[dmap].type&dmfTYPE)==dmCAVE) && mc.dungeon_map_tile)
14320 {
14321 draw_block(tempbmp,0,0,mc.dungeon_map_tile,mc.dungeon_map_cset,5,3);
14322 }
14323 else if(((DMaps[dmap].type&dmfTYPE)==dmOVERW || (DMaps[dmap].type&dmfTYPE)==dmBSOVERW) && mc.overworld_map_tile)
14324 {
14325 draw_block(tempbmp,0,0,mc.overworld_map_tile,mc.overworld_map_cset,5,3);
14326 }
14327
14328 masked_blit(dmapbmp_small,tempbmp,0,0,8,7,65,33);
14329
14330 blit(tempbmp,screen,0,0,x,y,w,h);
14331 destroy_bitmap(tempbmp);
14332
14333 }
14334
14335 int32_t d_dmaplist_proc(int32_t msg,DIALOG *d,int32_t c)
14336 {
14337 if(msg==MSG_DRAW)
14338 {
14339 int32_t dmap = d->d1;
14340 int32_t xy[6] = {44,92,128,100,128,110};
14341 //int32_t *xy = (int32_t*)(d->dp3);
14342 float temp_scale = 1.5;
14343
14344 drawdmap(dmap);
14345
14346 if(xy[0]>-1000&&xy[1]>-1000)
14347 {
14348 int32_t x = d->x+int32_t((xy[0]-2)*temp_scale);
14349 int32_t y = d->y+int32_t((xy[1]-2)*temp_scale);
14350 int32_t w = 84;
14351 int32_t h = 52;
14352 jwin_draw_frame(screen,x,y,w,h,FR_DEEP);
14353 drawdmap_screen(x+2,y+2,w-4,h-4,dmap);
14354 }
14355
14356 if(xy[2]>-1000&&xy[3]>-1000)
14357 {
14358 textprintf_ex(screen,get_zc_font(font_lfont_l),d->x+int32_t((xy[2])*temp_scale),d->y+int32_t((xy[3])*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Map: %-3d",DMaps[d->d1].map+1);
14359 }
14360
14361 if(xy[4]>-1000&&xy[5]>-1000)
14362 {
14363 textprintf_ex(screen,get_zc_font(font_lfont_l),d->x+int32_t((xy[4])*temp_scale),d->y+int32_t((xy[5])*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Level: %-3d",DMaps[d->d1].level);
14364 }
14365 }
14366
14367 return jwin_list_proc(msg,d,c);
14368 }
14369
14370 int32_t d_dropdmaplist_proc(int32_t msg,DIALOG *d,int32_t c)
14371 {
14372 if(msg==MSG_DRAW)
14373 {
14374 int32_t dmap = d->d1;
14375 int32_t *xy = (int32_t*)(d->dp3);
14376 float temp_scale = 1.5;
14377
14378 drawdmap(dmap);
14379
14380 if(xy[0]>-1000&&xy[1]>-1000)
14381 {
14382 int32_t x = d->x+int32_t((xy[0]-2)*temp_scale);
14383 int32_t y = d->y+int32_t((xy[1]-2)*temp_scale);
14384 int32_t w = 84;
14385 int32_t h = 52;
14386 jwin_draw_frame(screen,x,y,w,h,FR_DEEP);
14387 drawdmap_screen(x+2,y+2,w-4,h-4,dmap);
14388 }
14389
14390 if(xy[2]>-1000&&xy[3]>-1000)
14391 {
14392 textprintf_ex(screen,get_zc_font(font_lfont_l),d->x+int32_t((xy[2])*temp_scale),d->y+int32_t((xy[3])*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Map: %-3d",DMaps[d->d1].map+1);
14393 }
14394
14395 if(xy[4]>-1000&&xy[5]>-1000)
14396 {
14397 textprintf_ex(screen,get_zc_font(font_lfont_l),d->x+int32_t((xy[4])*temp_scale),d->y+int32_t((xy[5])*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Level: %-3d",DMaps[d->d1].level);
14398 }
14399 }
14400
14401 return jwin_droplist_proc(msg,d,c);
14402 }
14403
14404 void drawxmap(ALLEGRO_BITMAP* dest, int32_t themap, int32_t xoff, bool large, int dx, int dy)
14405 {
14406 ALLEGRO_STATE old_state;
14407 al_store_state(&old_state, ALLEGRO_STATE_TARGET_BITMAP);
14408
14409 al_set_target_bitmap(dest);
14410 al_clear_to_color(al_map_rgba(0, 0, 0, 0));
14411
14412 int32_t cols = (large ? 8 : 16);
14413 int32_t col_width = large ? 22 : 11;
14414 int32_t dot_width = (large ? 6 : 4);
14415 int32_t dot_offset = (large ? 7 : 3);
14416 int32_t l = 10;
14417
14418 for (int32_t y = 0; y < 8; y++)
14419 {
14420 for (int32_t x = 0; x < cols; x++)
14421 {
14422 if (x + xoff < 0 || x + xoff > 15)
14423 continue;
14424 mapscr* scr = &TheMaps[themap * MAPSCRS + y * 16 + x + (large ? xoff : 0)];
14425 if (!(scr->valid & mVALID))
14426 continue;
14427 al_draw_filled_rectangle(dx + (x * col_width), dy + (y * l), dx + (x * col_width + col_width), dy + ((y * l) + l), real_lc1(scr->color));
14428
14429 al_draw_filled_rectangle(dx + (x * col_width + dot_offset), dy + (y * l + 3), dx + (x * col_width + dot_offset + dot_width), dy + (y * l + l - 3), real_lc2(scr->color));
14430 }
14431 }
14432
14433 al_restore_state(&old_state);
14434 }
14435
14436 const char *dmapscriptdroplist(int32_t index, int32_t *list_size)
14437 {
14438 if(index<0)
14439 {
14440 *list_size = bidmaps_cnt;
14441 return NULL;
14442 }
14443
14444 return bidmaps[index].first.c_str();
14445 }
14446
14447
14448 //droplist like the dialog proc, naming scheme for this stuff is awful...
14449 8 static ListData dmapscript_list(dmapscriptdroplist, &a4fonts[font_pfont]);
14450
14451 //int32_t selectdmapxy[6] = {90,142,164,150,164,160};
14452 int32_t selectdmapxy[6] = {44,92,128,100,128,110};
14453
14454 8 static ListData dmap_list(dmaplist, &font);
14455
14456 static DIALOG selectdmap_dlg[] =
14457 {
14458 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
14459 8 { jwin_win_proc, 72-44, 56-30, 176+88+1, 120+74+1, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Select DMap", NULL, NULL },
14460 8 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
14461 8 { d_dmaplist_proc, 46, 50, 64+72+88+1, 60+24+1+2, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &dmap_list, NULL, selectdmapxy },
14462 8 { jwin_button_proc, 90, 152+44, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Edit", NULL, NULL },
14463 8 { jwin_button_proc, 170, 152+44, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Done", NULL, NULL },
14464 8 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_DEL, (void *) close_dlg, NULL, NULL },
14465 8 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_C, (void*)close_dlg, NULL, NULL },
14466 8 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_V, (void*)close_dlg, NULL, NULL },
14467 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
14468 };
14469
14470 8 static dmap copiedDMap;
14471 static byte dmapcopied = 0;
14472
14473 int32_t writesomedmaps(PACKFILE *f, int32_t first, int32_t last, int32_t max)
14474 {
14475
14476 dword section_version=V_DMAPS;
14477 dword section_cversion=CV_DMAPS;
14478 int32_t zversion = ZELDA_VERSION;
14479 int32_t zbuild = VERSION_BUILD;
14480
14481 if(!p_iputl(V_ZDMAP,f))
14482 {
14483 return 0;
14484 }
14485
14486 //section version info
14487 if(!p_iputl(zversion,f))
14488 {
14489 return 0;
14490 }
14491 if(!p_iputl(zbuild,f))
14492 {
14493 return 0;
14494 }
14495 if(!p_iputw(section_version,f))
14496 {
14497 new_return(2);
14498 }
14499
14500 if(!p_iputw(section_cversion,f))
14501 {
14502 new_return(3);
14503 }
14504 //max possible at this time
14505 if(!p_iputl(max,f))
14506 {
14507 new_return(4);
14508 }
14509 //first id written
14510 if(!p_iputl(first,f))
14511 {
14512 new_return(5);
14513 }
14514 //last id written
14515 if(!p_iputl(last,f))
14516 {
14517 new_return(6);
14518 }
14519 int32_t count = last-first;
14520 //number written
14521 if(!p_iputl(count,f))
14522 {
14523 new_return(7);
14524 }
14525
14526
14527 for ( int32_t i = first; i <= last; ++i )
14528 {
14529 if ( i > max ) break;
14530
14531 if(!p_putc(DMaps[i].map,f))
14532 {
14533 new_return(8);
14534 }
14535
14536 if(!p_iputw(DMaps[i].level,f))
14537 {
14538 new_return(9);
14539 }
14540
14541 if(!p_putc(DMaps[i].xoff,f))
14542 {
14543 new_return(10);
14544 }
14545
14546 if(!p_putc(DMaps[i].compass,f))
14547 {
14548 new_return(11);
14549 }
14550
14551 if(!p_iputw(DMaps[i].color,f))
14552 {
14553 new_return(12);
14554 }
14555
14556 if(!p_putc(DMaps[i].midi,f))
14557 {
14558 new_return(13);
14559 }
14560
14561 if(!p_putc(DMaps[i].cont,f))
14562 {
14563 new_return(14);
14564 }
14565
14566 if(!p_putc(DMaps[i].type,f))
14567 {
14568 new_return(15);
14569 }
14570
14571 for(int32_t j=0; j<8; j++)
14572 {
14573 if(!p_putc(DMaps[i].grid[j],f))
14574 {
14575 new_return(16);
14576 }
14577 }
14578
14579 //16
14580 if(!pfwrite(&DMaps[i].name,sizeof(DMaps[0].name),f))
14581 {
14582 new_return(17);
14583 }
14584
14585 if(!p_putwstr(DMaps[i].title,f))
14586 {
14587 new_return(18);
14588 }
14589
14590 if(!pfwrite(&DMaps[i].intro,sizeof(DMaps[0].intro),f))
14591 {
14592 new_return(19);
14593 }
14594
14595 if(!p_iputl(DMaps[i].minimap_1_tile,f))
14596 {
14597 new_return(20);
14598 }
14599
14600 if(!p_putc(DMaps[i].minimap_1_cset,f))
14601 {
14602 new_return(21);
14603 }
14604
14605 if(!p_iputl(DMaps[i].minimap_2_tile,f))
14606 {
14607 new_return(22);
14608 }
14609
14610 if(!p_putc(DMaps[i].minimap_2_cset,f))
14611 {
14612 new_return(23);
14613 }
14614
14615 if(!p_iputl(DMaps[i].largemap_1_tile,f))
14616 {
14617 new_return(24);
14618 }
14619
14620 if(!p_putc(DMaps[i].largemap_1_cset,f))
14621 {
14622 new_return(25);
14623 }
14624
14625 if(!p_iputl(DMaps[i].largemap_2_tile,f))
14626 {
14627 new_return(26);
14628 }
14629
14630 if(!p_putc(DMaps[i].largemap_2_cset,f))
14631 {
14632 new_return(27);
14633 }
14634
14635 if(!pfwrite(&DMaps[i].tmusic,sizeof(DMaps[0].tmusic),f))
14636 {
14637 new_return(28);
14638 }
14639
14640 if(!p_putc(DMaps[i].tmusictrack,f))
14641 {
14642 new_return(29);
14643 }
14644
14645 if(!p_putc(DMaps[i].active_subscreen,f))
14646 {
14647 new_return(30);
14648 }
14649
14650 if(!p_putc(DMaps[i].passive_subscreen,f))
14651 {
14652 new_return(31);
14653 }
14654
14655 byte disabled[32];
14656 memset(disabled,0,32);
14657
14658 for(int32_t j=0; j<MAXITEMS; j++)
14659 {
14660 if(DMaps[i].disableditems[j])
14661 {
14662 disabled[j/8] |= (1 << (j%8));
14663 }
14664 }
14665
14666 if(!pfwrite(disabled,32,f))
14667 {
14668 new_return(32);
14669 }
14670
14671 if(!p_iputl(DMaps[i].flags,f))
14672 {
14673 new_return(33);
14674 }
14675 if(!p_putc(DMaps[i].sideview,f))
14676 {
14677 new_return(30);
14678 }
14679 if(!p_iputw(DMaps[i].script,f))
14680 {
14681 new_return(31);
14682 }
14683 for ( int32_t q = 0; q < 8; q++ )
14684 {
14685 if(!p_iputl(DMaps[i].initD[q],f))
14686 {
14687 new_return(32);
14688 }
14689
14690 }
14691 for ( int32_t q = 0; q < 8; q++ )
14692 {
14693 for ( int32_t w = 0; w < 65; w++ )
14694 {
14695 if (!p_putc(DMaps[i].initD_label[q][w],f))
14696 {
14697 new_return(33);
14698 }
14699 }
14700 }
14701 if(!p_iputw(DMaps[i].active_sub_script,f))
14702 {
14703 new_return(34);
14704 }
14705 if(!p_iputw(DMaps[i].passive_sub_script,f))
14706 {
14707 new_return(35);
14708 }
14709 for(int32_t q = 0; q < 8; ++q)
14710 {
14711 if(!p_iputl(DMaps[i].sub_initD[q],f))
14712 {
14713 new_return(36);
14714 }
14715 }
14716 for(int32_t q = 0; q < 8; ++q)
14717 {
14718 for(int32_t w = 0; w < 65; ++w)
14719 {
14720 if(!p_putc(DMaps[i].sub_initD_label[q][w],f))
14721 {
14722 new_return(37);
14723 }
14724 }
14725 }
14726 if(!p_iputw(DMaps[i].onmap_script,f))
14727 {
14728 new_return(35);
14729 }
14730 for(int32_t q = 0; q < 8; ++q)
14731 {
14732 if(!p_iputl(DMaps[i].onmap_initD[q],f))
14733 {
14734 new_return(36);
14735 }
14736 }
14737 for(int32_t q = 0; q < 8; ++q)
14738 {
14739 for(int32_t w = 0; w < 65; ++w)
14740 {
14741 if(!p_putc(DMaps[i].onmap_initD_label[q][w],f))
14742 {
14743 new_return(37);
14744 }
14745 }
14746 }
14747 if (!p_iputw(DMaps[i].mirrorDMap, f))
14748 {
14749 new_return(38);
14750 }
14751 if (!p_iputl(DMaps[i].tmusic_loop_start, f))
14752 {
14753 new_return(39);
14754 }
14755 if (!p_iputl(DMaps[i].tmusic_loop_end, f))
14756 {
14757 new_return(40);
14758 }
14759 if (!p_iputl(DMaps[i].tmusic_xfade_in, f))
14760 {
14761 new_return(41);
14762 }
14763 if (!p_iputl(DMaps[i].tmusic_xfade_out, f))
14764 {
14765 new_return(42);
14766 }
14767 }
14768
14769 return 1;
14770 }
14771
14772
14773 int32_t readsomedmaps(PACKFILE *f)
14774 {
14775 dword section_version = 0;
14776 dword section_cversion = 0;
14777 int32_t zversion = 0;
14778 int32_t zbuild = 0;
14779 dmap tempdmap{};
14780
14781 int32_t first = 0, last = 0, max = 0, count = 0;
14782 int32_t datatype_version = 0;
14783
14784 //char dmapstring[64]={0};
14785 //section version info
14786 if(!p_igetl(&datatype_version,f))
14787 {
14788 return 0;
14789 }
14790 if ( datatype_version < 0 )
14791 {
14792 if(!p_igetl(&zversion,f))
14793 {
14794 return 0;
14795 }
14796 }
14797 else
14798 {
14799 zversion = datatype_version;
14800 }
14801 if(!p_igetl(&zbuild,f))
14802 {
14803 return 0;
14804 }
14805
14806 if(!p_igetw(&section_version,f))
14807 {
14808 return 0;
14809 }
14810
14811 if(!p_igetw(&section_cversion,f))
14812 {
14813 return 0;
14814 }
14815 if ( datatype_version < 0 )
14816 {
14817 if(!p_igetl(&max,f))
14818 {
14819 return 0;
14820 }
14821 if(!p_igetl(&first,f))
14822 {
14823 return 0;
14824 }
14825 if(!p_igetl(&last,f))
14826 {
14827 return 0;
14828 }
14829 if(!p_igetl(&count,f))
14830 {
14831 return 0;
14832 }
14833 }
14834 else
14835 {
14836 first = 0;
14837 last = 0;
14838 count = 1;
14839 max = 255;
14840 }
14841
14842
14843
14844
14845 al_trace("readsomedmaps section_version: %d\n", section_version);
14846 al_trace("readsomedmaps section_cversion: %d\n", section_cversion);
14847
14848 if ( zversion > ZELDA_VERSION )
14849 {
14850 al_trace("Cannot read .zdmap packfile made in ZC version (%x) in this version of ZC (%x)\n", zversion, ZELDA_VERSION);
14851 return 0;
14852 }
14853 else if (( section_version > V_DMAPS ) || ( section_version == V_DMAPS && section_cversion > CV_DMAPS ) )
14854 {
14855 al_trace("Cannot read .zdmap packfile made using V_DMAPS (%d) subversion (%d)\n", section_version, section_cversion);
14856 return 0;
14857 }
14858 else
14859 {
14860 al_trace("Reading a .zdmap packfile made in ZC Version: %x, Build: %d\n", zversion, zbuild);
14861 }
14862 //if(!pfread(&dmapstring, 64, f))
14863 //{
14864 // return 0;
14865 //}
14866
14867
14868
14869 for ( int32_t i = first; i <= last; ++i )
14870 {
14871 if(!p_getc(&tempdmap.map,f))
14872 {
14873 return 0;
14874 }
14875
14876 if(!p_igetw(&tempdmap.level,f))
14877 {
14878 return 0;
14879 }
14880
14881 if(!p_getc(&tempdmap.xoff,f))
14882 {
14883 return 0;
14884 }
14885
14886 if(!p_getc(&tempdmap.compass,f))
14887 {
14888 return 0;
14889 }
14890
14891 if(!p_igetw(&tempdmap.color,f))
14892 {
14893 return 0;
14894 }
14895
14896 if(!p_getc(&tempdmap.midi,f))
14897 {
14898 return 0;
14899 }
14900
14901 if(!p_getc(&tempdmap.cont,f))
14902 {
14903 return 0;
14904 }
14905
14906 if(!p_getc(&tempdmap.type,f))
14907 {
14908 return 0;
14909 }
14910
14911 for(int32_t j=0; j<8; j++)
14912 {
14913 if(!p_getc(&tempdmap.grid[j],f))
14914 {
14915 return 0;
14916 }
14917 }
14918
14919 //16
14920 if(!pfread(&tempdmap.name,sizeof(DMaps[0].name),f))
14921 {
14922 return 0;
14923 }
14924
14925 if (section_version<20)
14926 {
14927 char title[22];
14928 if (!p_getstr(title, sizeof(title) - 1, f))
14929 {
14930 return 0;
14931 }
14932 tempdmap.title.assign(title);
14933 }
14934 else
14935 {
14936 if (!p_getwstr(&tempdmap.title, f))
14937 {
14938 return 0;
14939 }
14940 }
14941
14942 if(!pfread(&tempdmap.intro,sizeof(DMaps[0].intro),f))
14943 {
14944 return 0;
14945 }
14946
14947 if(!p_igetl(&tempdmap.minimap_1_tile,f))
14948 {
14949 return 0;
14950 }
14951
14952 if(!p_getc(&tempdmap.minimap_1_cset,f))
14953 {
14954 return 0;
14955 }
14956
14957 if(!p_igetl(&tempdmap.minimap_2_tile,f))
14958 {
14959 return 0;
14960 }
14961
14962 if(!p_getc(&tempdmap.minimap_2_cset,f))
14963 {
14964 return 0;
14965 }
14966
14967 if(!p_igetl(&tempdmap.largemap_1_tile,f))
14968 {
14969 return 0;
14970 }
14971
14972 if(!p_getc(&tempdmap.largemap_1_cset,f))
14973 {
14974 return 0;
14975 }
14976
14977 if(!p_igetl(&tempdmap.largemap_2_tile,f))
14978 {
14979 return 0;
14980 }
14981
14982 if(!p_getc(&tempdmap.largemap_2_cset,f))
14983 {
14984 return 0;
14985 }
14986
14987 if(!pfread(&tempdmap.tmusic,sizeof(DMaps[0].tmusic),f))
14988 {
14989 return 0;
14990 }
14991
14992 if(!p_getc(&tempdmap.tmusictrack,f))
14993 {
14994 return 0;
14995 }
14996
14997 if(!p_getc(&tempdmap.active_subscreen,f))
14998 {
14999 return 0;
15000 }
15001
15002 if(!p_getc(&tempdmap.passive_subscreen,f))
15003 {
15004 return 0;
15005 }
15006
15007 byte disabled[32];
15008 memset(disabled,0,32);
15009
15010 if(!pfread(&disabled, 32, f)) return 0;
15011
15012 for(int32_t j=0; j<MAXITEMS; j++)
15013 {
15014 if(disabled[j/8] & (1 << (j%8))) tempdmap.disableditems[j]=1;
15015 else tempdmap.disableditems[j]=0;
15016 }
15017
15018
15019 if(!p_igetl(&tempdmap.flags,f))
15020 {
15021 return 0;
15022 }
15023 if ( zversion >= 0x255 )
15024 {
15025 if ( section_version >= 14 )
15026 {
15027 //2.55 starts here
15028 if(!p_getc(&tempdmap.sideview,f))
15029 {
15030 return 0;
15031 }
15032 if(!p_igetw(&tempdmap.script,f))
15033 {
15034 return 0;
15035 }
15036 for ( int32_t q = 0; q < 8; q++ )
15037 {
15038 if(!p_igetl(&tempdmap.initD[q],f))
15039 {
15040 return 0;
15041 }
15042
15043 }
15044 for ( int32_t q = 0; q < 8; q++ )
15045 {
15046 for ( int32_t w = 0; w < 65; w++ )
15047 {
15048 if (!p_getc(&tempdmap.initD_label[q][w],f))
15049 {
15050 return 0;
15051 }
15052 }
15053 }
15054 if(!p_igetw(&tempdmap.active_sub_script,f))
15055 {
15056 return 0;
15057 }
15058 if(!p_igetw(&tempdmap.passive_sub_script,f))
15059 {
15060 return 0;
15061 }
15062 for(int32_t q = 0; q < 8; ++q)
15063 {
15064 if(!p_igetl(&tempdmap.sub_initD[q],f))
15065 {
15066 return 0;
15067 }
15068 }
15069 for(int32_t q = 0; q < 8; ++q)
15070 {
15071 for(int32_t w = 0; w < 65; ++w)
15072 {
15073 if(!p_getc(&tempdmap.sub_initD_label[q][w],f))
15074 {
15075 return 0;
15076 }
15077 }
15078 }
15079 if(!p_igetw(&tempdmap.onmap_script,f))
15080 {
15081 return 0;
15082 }
15083 for(int32_t q = 0; q < 8; ++q)
15084 {
15085 if(!p_igetl(&tempdmap.onmap_initD[q],f))
15086 {
15087 return 0;
15088 }
15089 }
15090 for(int32_t q = 0; q < 8; ++q)
15091 {
15092 for(int32_t w = 0; w < 65; ++w)
15093 {
15094 if(!p_getc(&tempdmap.onmap_initD_label[q][w],f))
15095 {
15096 return 0;
15097 }
15098 }
15099 }
15100 if (!p_igetw(&tempdmap.mirrorDMap, f))
15101 {
15102 return 0;
15103 }
15104 if (!p_igetl(&tempdmap.tmusic_loop_start, f))
15105 {
15106 return 0;
15107 }
15108 if (!p_igetl(&tempdmap.tmusic_loop_end, f))
15109 {
15110 return 0;
15111 }
15112 if (!p_igetl(&tempdmap.tmusic_xfade_in, f))
15113 {
15114 return 0;
15115 }
15116 if (!p_igetl(&tempdmap.tmusic_xfade_out, f))
15117 {
15118 return 0;
15119 }
15120 }
15121 }
15122 DMaps[i].clear();
15123 DMaps[i] = tempdmap;
15124 }
15125
15126 return 1;
15127 }
15128
15129
15130
15131 int32_t writeonedmap(PACKFILE *f, int32_t i)
15132 {
15133
15134 dword section_version=V_DMAPS;
15135 dword section_cversion=CV_DMAPS;
15136 int32_t zversion = ZELDA_VERSION;
15137 int32_t zbuild = VERSION_BUILD;
15138
15139
15140 //section version info
15141 if(!p_iputl(V_ZDMAP,f))
15142 {
15143 return 0;
15144 }
15145 if(!p_iputl(zversion,f))
15146 {
15147 return 0;
15148 }
15149 if(!p_iputl(zbuild,f))
15150 {
15151 return 0;
15152 }
15153 if(!p_iputw(section_version,f))
15154 {
15155 new_return(2);
15156 }
15157
15158 if(!p_iputw(section_cversion,f))
15159 {
15160 new_return(3);
15161 }
15162
15163
15164
15165 if(!p_putc(DMaps[i].map,f))
15166 {
15167 new_return(6);
15168 }
15169
15170 if(!p_iputw(DMaps[i].level,f))
15171 {
15172 new_return(7);
15173 }
15174
15175 if(!p_putc(DMaps[i].xoff,f))
15176 {
15177 new_return(8);
15178 }
15179
15180 if(!p_putc(DMaps[i].compass,f))
15181 {
15182 new_return(9);
15183 }
15184
15185 if(!p_iputw(DMaps[i].color,f))
15186 {
15187 new_return(10);
15188 }
15189
15190 if(!p_putc(DMaps[i].midi,f))
15191 {
15192 new_return(11);
15193 }
15194
15195 if(!p_putc(DMaps[i].cont,f))
15196 {
15197 new_return(12);
15198 }
15199
15200 if(!p_putc(DMaps[i].type,f))
15201 {
15202 new_return(13);
15203 }
15204
15205 for(int32_t j=0; j<8; j++)
15206 {
15207 if(!p_putc(DMaps[i].grid[j],f))
15208 {
15209 new_return(14);
15210 }
15211 }
15212
15213 //16
15214 if(!pfwrite(&DMaps[i].name,sizeof(DMaps[0].name),f))
15215 {
15216 new_return(15);
15217 }
15218
15219 if(!pfwrite(&DMaps[i].title,sizeof(DMaps[0].title),f))
15220 {
15221 new_return(16);
15222 }
15223
15224 if(!pfwrite(&DMaps[i].intro,sizeof(DMaps[0].intro),f))
15225 {
15226 new_return(17);
15227 }
15228
15229 if(!p_iputl(DMaps[i].minimap_1_tile,f))
15230 {
15231 new_return(18);
15232 }
15233
15234 if(!p_putc(DMaps[i].minimap_1_cset,f))
15235 {
15236 new_return(19);
15237 }
15238
15239 if(!p_iputl(DMaps[i].minimap_2_tile,f))
15240 {
15241 new_return(20);
15242 }
15243
15244 if(!p_putc(DMaps[i].minimap_2_cset,f))
15245 {
15246 new_return(21);
15247 }
15248
15249 if(!p_iputl(DMaps[i].largemap_1_tile,f))
15250 {
15251 new_return(22);
15252 }
15253
15254 if(!p_putc(DMaps[i].largemap_1_cset,f))
15255 {
15256 new_return(23);
15257 }
15258
15259 if(!p_iputl(DMaps[i].largemap_2_tile,f))
15260 {
15261 new_return(24);
15262 }
15263
15264 if(!p_putc(DMaps[i].largemap_2_cset,f))
15265 {
15266 new_return(25);
15267 }
15268
15269 if(!pfwrite(&DMaps[i].tmusic,sizeof(DMaps[0].tmusic),f))
15270 {
15271 new_return(26);
15272 }
15273
15274 if(!p_putc(DMaps[i].tmusictrack,f))
15275 {
15276 new_return(25);
15277 }
15278
15279 if(!p_putc(DMaps[i].active_subscreen,f))
15280 {
15281 new_return(26);
15282 }
15283
15284 if(!p_putc(DMaps[i].passive_subscreen,f))
15285 {
15286 new_return(27);
15287 }
15288
15289 byte disabled[32];
15290 memset(disabled,0,32);
15291
15292 for(int32_t j=0; j<MAXITEMS; j++)
15293 {
15294 if(DMaps[i].disableditems[j])
15295 {
15296 disabled[j/8] |= (1 << (j%8));
15297 }
15298 }
15299
15300 if(!pfwrite(disabled,32,f))
15301 {
15302 new_return(28);
15303 }
15304
15305 if(!p_iputl(DMaps[i].flags,f))
15306 {
15307 new_return(29);
15308 }
15309 if(!p_putc(DMaps[i].sideview,f))
15310 {
15311 new_return(30);
15312 }
15313 if(!p_iputw(DMaps[i].script,f))
15314 {
15315 new_return(31);
15316 }
15317 for ( int32_t q = 0; q < 8; q++ )
15318 {
15319 if(!p_iputl(DMaps[i].initD[q],f))
15320 {
15321 new_return(32);
15322 }
15323
15324 }
15325 for ( int32_t q = 0; q < 8; q++ )
15326 {
15327 for ( int32_t w = 0; w < 65; w++ )
15328 {
15329 if (!p_putc(DMaps[i].initD_label[q][w],f))
15330 {
15331 new_return(33);
15332 }
15333 }
15334 }
15335 if(!p_iputw(DMaps[i].active_sub_script,f))
15336 {
15337 new_return(34);
15338 }
15339 if(!p_iputw(DMaps[i].passive_sub_script,f))
15340 {
15341 new_return(35);
15342 }
15343 for(int32_t q = 0; q < 8; ++q)
15344 {
15345 if(!p_iputl(DMaps[i].sub_initD[q],f))
15346 {
15347 new_return(36);
15348 }
15349 }
15350 for(int32_t q = 0; q < 8; ++q)
15351 {
15352 for(int32_t w = 0; w < 65; ++w)
15353 {
15354 if(!p_putc(DMaps[i].sub_initD_label[q][w],f))
15355 {
15356 new_return(37);
15357 }
15358 }
15359 }
15360 if(!p_iputw(DMaps[i].onmap_script,f))
15361 {
15362 new_return(35);
15363 }
15364 for(int32_t q = 0; q < 8; ++q)
15365 {
15366 if(!p_iputl(DMaps[i].onmap_initD[q],f))
15367 {
15368 new_return(36);
15369 }
15370 }
15371 for(int32_t q = 0; q < 8; ++q)
15372 {
15373 for(int32_t w = 0; w < 65; ++w)
15374 {
15375 if(!p_putc(DMaps[i].onmap_initD_label[q][w],f))
15376 {
15377 new_return(37);
15378 }
15379 }
15380 }
15381 if (!p_iputw(DMaps[i].mirrorDMap, f))
15382 {
15383 new_return(38);
15384 }
15385 if (!p_iputl(DMaps[i].tmusic_loop_start, f))
15386 {
15387 new_return(39);
15388 }
15389 if (!p_iputl(DMaps[i].tmusic_loop_end, f))
15390 {
15391 new_return(40);
15392 }
15393 if (!p_iputl(DMaps[i].tmusic_xfade_in, f))
15394 {
15395 new_return(41);
15396 }
15397 if (!p_iputl(DMaps[i].tmusic_xfade_out, f))
15398 {
15399 new_return(42);
15400 }
15401
15402 return 1;
15403 }
15404
15405
15406 int32_t readonedmap(PACKFILE *f, int32_t index)
15407 {
15408 dword section_version = 0;
15409 dword section_cversion = 0;
15410 int32_t zversion = 0;
15411 int32_t zbuild = 0;
15412 dmap tempdmap{};
15413 int32_t datatype_version = 0;
15414 int32_t first = 0;
15415 int32_t last = 0;
15416 int32_t max = 0;
15417 int32_t count = 0;
15418
15419 //char dmapstring[64]={0};
15420 //section version info
15421 if(!p_igetl(&datatype_version,f))
15422 {
15423 return 0;
15424 }
15425 if ( datatype_version < 0 )
15426 {
15427 if(!p_igetl(&zversion,f))
15428 {
15429 return 0;
15430 }
15431 }
15432 else
15433 {
15434 zversion = datatype_version;
15435 }
15436 if(!p_igetl(&zbuild,f))
15437 {
15438 return 0;
15439 }
15440
15441 if(!p_igetw(&section_version,f))
15442 {
15443 return 0;
15444 }
15445
15446 if(!p_igetw(&section_cversion,f))
15447 {
15448 return 0;
15449 }
15450 al_trace("readonedmap section_version: %d\n", section_version);
15451 al_trace("readonedmap section_cversion: %d\n", section_cversion);
15452
15453
15454 if ( datatype_version < 0 )
15455 {
15456 if(!p_igetl(&max,f))
15457 {
15458 return 0;
15459 }
15460 if(!p_igetl(&first,f))
15461 {
15462 return 0;
15463 }
15464 if(!p_igetl(&last,f))
15465 {
15466 return 0;
15467 }
15468 if(!p_igetl(&count,f))
15469 {
15470 return 0;
15471 }
15472 }
15473 if ( zversion > ZELDA_VERSION )
15474 {
15475 al_trace("Cannot read .zdmap packfile made in ZC version (%x) in this version of ZC (%x)\n", zversion, ZELDA_VERSION);
15476 return 0;
15477 }
15478 else if (( section_version > V_DMAPS ) || ( section_version == V_DMAPS && section_cversion > CV_DMAPS ) )
15479 {
15480 al_trace("Cannot read .zdmap packfile made using V_DMAPS (%d) subversion (%d)\n", section_version, section_cversion);
15481 return 0;
15482 }
15483 else
15484 {
15485 al_trace("Reading a .zdmap packfile made in ZC Version: %x, Build: %d\n", zversion, zbuild);
15486 }
15487 //if(!pfread(&dmapstring, 64, f))
15488 //{
15489 // return 0;
15490 //}
15491
15492
15493
15494
15495 if(!p_getc(&tempdmap.map,f))
15496 {
15497 return 0;
15498 }
15499
15500 if(!p_igetw(&tempdmap.level,f))
15501 {
15502 return 0;
15503 }
15504
15505 if(!p_getc(&tempdmap.xoff,f))
15506 {
15507 return 0;
15508 }
15509
15510 if(!p_getc(&tempdmap.compass,f))
15511 {
15512 return 0;
15513 }
15514
15515 if(!p_igetw(&tempdmap.color,f))
15516 {
15517 return 0;
15518 }
15519
15520 if(!p_getc(&tempdmap.midi,f))
15521 {
15522 return 0;
15523 }
15524
15525 if(!p_getc(&tempdmap.cont,f))
15526 {
15527 return 0;
15528 }
15529
15530 if(!p_getc(&tempdmap.type,f))
15531 {
15532 return 0;
15533 }
15534
15535 for(int32_t j=0; j<8; j++)
15536 {
15537 if(!p_getc(&tempdmap.grid[j],f))
15538 {
15539 return 0;
15540 }
15541 }
15542
15543 //16
15544 if(!pfread(&tempdmap.name,sizeof(DMaps[0].name),f))
15545 {
15546 return 0;
15547 }
15548
15549 if (section_version<20)
15550 {
15551 char title[22];
15552 if (!p_getstr(title, sizeof(title) - 1, f))
15553 {
15554 return 0;
15555 }
15556 tempdmap.title.assign(title);
15557 }
15558 else
15559 {
15560 if (!p_getwstr(&tempdmap.title, f))
15561 {
15562 return 0;
15563 }
15564 }
15565
15566 if(!pfread(&tempdmap.title,sizeof(DMaps[0].title),f))
15567 {
15568 return 0;
15569 }
15570
15571 if(!pfread(&tempdmap.intro,sizeof(DMaps[0].intro),f))
15572 {
15573 return 0;
15574 }
15575
15576 if(!p_igetl(&tempdmap.minimap_1_tile,f))
15577 {
15578 return 0;
15579 }
15580
15581 if(!p_getc(&tempdmap.minimap_1_cset,f))
15582 {
15583 return 0;
15584 }
15585
15586 if(!p_igetl(&tempdmap.minimap_2_tile,f))
15587 {
15588 return 0;
15589 }
15590
15591 if(!p_getc(&tempdmap.minimap_2_cset,f))
15592 {
15593 return 0;
15594 }
15595
15596 if(!p_igetl(&tempdmap.largemap_1_tile,f))
15597 {
15598 return 0;
15599 }
15600
15601 if(!p_getc(&tempdmap.largemap_1_cset,f))
15602 {
15603 return 0;
15604 }
15605
15606 if(!p_igetl(&tempdmap.largemap_2_tile,f))
15607 {
15608 return 0;
15609 }
15610
15611 if(!p_getc(&tempdmap.largemap_2_cset,f))
15612 {
15613 return 0;
15614 }
15615
15616 if(!pfread(&tempdmap.tmusic,sizeof(DMaps[0].tmusic),f))
15617 {
15618 return 0;
15619 }
15620
15621 if(!p_getc(&tempdmap.tmusictrack,f))
15622 {
15623 return 0;
15624 }
15625
15626 if(!p_getc(&tempdmap.active_subscreen,f))
15627 {
15628 return 0;
15629 }
15630
15631 if(!p_getc(&tempdmap.passive_subscreen,f))
15632 {
15633 return 0;
15634 }
15635
15636 byte disabled[32];
15637 memset(disabled,0,32);
15638
15639 if(!pfread(&disabled, 32, f)) return 0;
15640
15641 for(int32_t j=0; j<MAXITEMS; j++)
15642 {
15643 if(disabled[j/8] & (1 << (j%8))) tempdmap.disableditems[j]=1;
15644 else tempdmap.disableditems[j]=0;
15645 }
15646
15647
15648 if(!p_igetl(&tempdmap.flags,f))
15649 {
15650 return 0;
15651 }
15652 if ( zversion >= 0x255 )
15653 {
15654 if ( section_version >= 14 )
15655 {
15656 //2.55 starts here
15657 if(!p_getc(&tempdmap.sideview,f))
15658 {
15659 return 0;
15660 }
15661 if(!p_igetw(&tempdmap.script,f))
15662 {
15663 return 0;
15664 }
15665 for ( int32_t q = 0; q < 8; q++ )
15666 {
15667 if(!p_igetl(&tempdmap.initD[q],f))
15668 {
15669 return 0;
15670 }
15671
15672 }
15673 for ( int32_t q = 0; q < 8; q++ )
15674 {
15675 for ( int32_t w = 0; w < 65; w++ )
15676 {
15677 if (!p_getc(&tempdmap.initD_label[q][w],f))
15678 {
15679 return 0;
15680 }
15681 }
15682 }
15683 if(!p_igetw(&tempdmap.active_sub_script,f))
15684 {
15685 return 0;
15686 }
15687 if(!p_igetw(&tempdmap.passive_sub_script,f))
15688 {
15689 return 0;
15690 }
15691 for(int32_t q = 0; q < 8; ++q)
15692 {
15693 if(!p_igetl(&tempdmap.sub_initD[q],f))
15694 {
15695 return 0;
15696 }
15697 }
15698 for(int32_t q = 0; q < 8; ++q)
15699 {
15700 for(int32_t w = 0; w < 65; ++w)
15701 {
15702 if(!p_getc(&tempdmap.sub_initD_label[q][w],f))
15703 {
15704 return 0;
15705 }
15706 }
15707 }
15708 if(!p_igetw(&tempdmap.onmap_script,f))
15709 {
15710 return 0;
15711 }
15712 for(int32_t q = 0; q < 8; ++q)
15713 {
15714 if(!p_igetl(&tempdmap.onmap_initD[q],f))
15715 {
15716 return 0;
15717 }
15718 }
15719 for(int32_t q = 0; q < 8; ++q)
15720 {
15721 for(int32_t w = 0; w < 65; ++w)
15722 {
15723 if(!p_getc(&tempdmap.onmap_initD_label[q][w],f))
15724 {
15725 return 0;
15726 }
15727 }
15728 }
15729 if (!p_igetw(&tempdmap.mirrorDMap, f))
15730 {
15731 return 0;
15732 }
15733 if (!p_igetl(&tempdmap.tmusic_loop_start, f))
15734 {
15735 return 0;
15736 }
15737 if (!p_igetl(&tempdmap.tmusic_loop_end, f))
15738 {
15739 return 0;
15740 }
15741 if (!p_igetl(&tempdmap.tmusic_xfade_in, f))
15742 {
15743 return 0;
15744 }
15745 if (!p_igetl(&tempdmap.tmusic_xfade_out, f))
15746 {
15747 return 0;
15748 }
15749 }
15750 }
15751 DMaps[index] = tempdmap;
15752
15753 return 1;
15754 }
15755
15756 void dmap_rclick_func(int32_t index, int32_t x, int32_t y)
15757 {
15758 if(((unsigned)index)>MAXDMAPS)
15759 return;
15760
15761 NewMenu rcmenu {
15762 { "&Copy", [&]()
15763 {
15764 copiedDMap = DMaps[index];
15765 dmapcopied = 1;
15766 } },
15767 { "Paste", "&v", [&]()
15768 {
15769 DMaps[index] = copiedDMap;
15770 selectdmap_dlg[2].flags |= D_DIRTY;
15771 saved = false;
15772 }, 0, !dmapcopied },
15773 { "&Save", [&]()
15774 {
15775 if(!getname("Save DMAP(.zdmap)", "zdmap", NULL,datapath,false))
15776 return;
15777 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
15778 if(!f) return;
15779 writesomedmaps(f,index, index, MAXDMAPS);
15780 pack_fclose(f);
15781 } },
15782 { "&Load", [&]()
15783 {
15784 if(!getname("Load DMAP(.zdmap)", "zdmap", NULL,datapath,false))
15785 return;
15786 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
15787 if(!f) return;
15788
15789 if (!readonedmap(f,index))
15790 {
15791 al_trace("Could not read from .zdmap packfile %s\n", temppath);
15792 jwin_alert("ZDMAP File: Error","Could not load the specified DMap.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
15793 }
15794
15795 pack_fclose(f);
15796 selectdmap_dlg[2].flags |= D_DIRTY; //Causes the dialogie list to refresh, updating the item name.
15797 saved = false;
15798 } },
15799 };
15800 rcmenu.pop(x, y);
15801 }
15802
15803
15804 int32_t onDmaps()
15805 {
15806 int32_t ret;
15807 char buf[40];
15808 dmapcopied = 0;
15809 dmap_list_size=MAXDMAPS;
15810 number_list_zero=true;
15811 selectdmap_dlg[0].dp2=get_zc_font(font_lfont);
15812 selectdmap_dlg[2].dp3 = (void *)&dmap_rclick_func;
15813 selectdmap_dlg[2].flags|=(D_USER<<1);
15814
15815 large_dialog(selectdmap_dlg);
15816
15817
15818
15819 ret=do_zqdialog(selectdmap_dlg,2);
15820 dmap* pSelectedDmap = 0;
15821
15822
15823
15824 while(ret!=4&&ret!=0)
15825 {
15826 int32_t d=selectdmap_dlg[2].d1;
15827
15828 if(ret==6) //copy
15829 {
15830 pSelectedDmap = &DMaps[d];
15831 }
15832 else if(ret==7 && pSelectedDmap != 0 ) //paste
15833 {
15834 if( pSelectedDmap != &DMaps[d] )
15835 {
15836 DMaps[d] = *pSelectedDmap;
15837 saved=false;
15838 }
15839 }
15840 else if(ret==5)
15841 {
15842 sprintf(buf,"Delete DMap %d?",d);
15843
15844 if(jwin_alert("Confirm Delete",buf,NULL,NULL,"&Yes","&No",'y','n',get_zc_font(font_lfont))==1)
15845 {
15846 reset_dmap(d);
15847 saved=false;
15848 }
15849 }
15850 else
15851 {
15852 call_editdmap_dialog(d);
15853 }
15854
15855 ret=do_zqdialog(selectdmap_dlg,2);
15856 }
15857
15858 return D_O_K;
15859 }
15860
15861 /*******************************/
15862 /********** onMidis **********/
15863 /*******************************/
15864
15865 static DIALOG editmidi_dlg[] =
15866 {
15867 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
15868 { jwin_win_proc, 24, 20, 273, 189, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "MIDI Specs", NULL, NULL },
15869 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
15870 // 2
15871 { jwin_text_proc, 56, 94-16, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "MIDI:", NULL, NULL },
15872 { jwin_text_proc, 104, 94-16, 48, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
15873 { jwin_text_proc, 56, 114, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Name:", NULL, NULL },
15874 { jwin_edit_proc, 104, 114-4, 160, 16, vc(12), vc(1), 0, 0, 35, 0, NULL, NULL, NULL },
15875 { jwin_text_proc, 56, 124-4+12, 56, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Volume:", NULL, NULL },
15876 { jwin_edit_proc, 120, 124-4+12-4, 32, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
15877 // 8
15878 { jwin_check_proc, 176, 124+12-4, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, (void *) "Loop", NULL, NULL },
15879 // 9
15880 { jwin_button_proc, 50, 72-24, 57, 21, vc(14), vc(1), 'l', D_EXIT, 0, 0, (void *) "&Load", NULL, NULL },
15881 { jwin_iconbutton_proc, 116, 72-24, 33, 21, vc(14), vc(1), 0, D_EXIT, BTNICON_STOPSQUARE, 0, NULL, NULL, NULL },
15882 { jwin_iconbutton_proc, 156, 72-24, 33, 21, vc(14), vc(1), 0, D_EXIT, BTNICON_ARROW_RIGHT, 0, NULL, NULL, NULL },
15883 { jwin_iconbutton_proc, 196, 72-24, 33, 21, vc(14), vc(1), 0, D_EXIT, BTNICON_ARROW_RIGHT2, 0, NULL, NULL, NULL },
15884 { jwin_iconbutton_proc, 236, 72-24, 33, 21, vc(14), vc(1), 0, D_EXIT, BTNICON_ARROW_RIGHT3, 0, NULL, NULL, NULL },
15885 // 14
15886 { jwin_text_proc, 56, 134+4+12, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start:", NULL, NULL },
15887 { jwin_edit_proc, 112, 134+12, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15888 { jwin_text_proc, 176, 134+12+4, 56, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Loop Start:", NULL, NULL },
15889 { jwin_edit_proc, 240, 134+12, 40, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15890 { jwin_text_proc, 176, 144+12+12, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Loop End:", NULL, NULL },
15891 { jwin_edit_proc, 240, 144+12+12-4, 40, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15892 // 20
15893 { jwin_text_proc, 176, 94-16, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Position:", NULL, NULL },
15894 { jwin_text_proc, 217, 94-16, 32, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
15895 { jwin_text_proc, 176, 104-8, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Length:", NULL, NULL },
15896 { jwin_text_proc, 216, 104-8, 32, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
15897 { jwin_text_proc, 56, 104-8, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Time:", NULL, NULL },
15898 { jwin_text_proc, 104, 104-8, 32, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
15899 // 26
15900 { jwin_check_proc, 56, 144+12+12, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, (void *) "Disable Saving", NULL, NULL },
15901 { jwin_button_proc, 90, 160+12+12, 61, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
15902 { jwin_button_proc, 170, 160+12+12, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
15903 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
15904 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
15905 };
15906
15907
15908 void edit_tune(int32_t i)
15909 {
15910 // TO DO : adapt for non-midi formats
15911 int32_t ret,loop,volume;
15912 byte flags;
15913 int32_t start,loop_start,loop_end;
15914
15915 char title[36];
15916 char volume_str[8];
15917 char start_str[16];
15918 char loop_start_str[16];
15919 char loop_end_str[16];
15920 char len_str[16];
15921 char pos_str[16];
15922 // char format_str[8];
15923 // int32_t format;
15924
15925 void *data = customtunes[i].data;
15926
15927 if(customtunes[i].format == MFORMAT_MIDI) get_midi_info((MIDI*) data,&Midi_Info);
15928
15929 volume = customtunes[i].volume;
15930 loop = customtunes[i].loop;
15931 flags = customtunes[i].flags;
15932 start = customtunes[i].start;
15933 loop_start = customtunes[i].loop_start;
15934 loop_end = customtunes[i].loop_end;
15935
15936 strcpy(title,customtunes[i].title);
15937
15938 editmidi_dlg[0].dp2=get_zc_font(font_lfont);
15939
15940 large_dialog(editmidi_dlg);
15941 editmidi_dlg[13].dp2 = font;
15942 editmidi_dlg[12].dp2 = font;
15943 editmidi_dlg[11].dp2 = font;
15944 editmidi_dlg[10].dp2 = font;
15945
15946 do
15947 {
15948 sprintf(volume_str,"%d",volume);
15949 sprintf(start_str,"%d",start);
15950 sprintf(loop_start_str,"%d",loop_start);
15951 sprintf(loop_end_str,"%d",loop_end);
15952 sprintf(len_str,"%d",Midi_Info.len_beats);
15953 sprintf(pos_str,"%ld",midi_pos);
15954
15955 editmidi_dlg[3].dp = data?(void *) "Loaded":(void *) "Empty";
15956 editmidi_dlg[5].dp = title;
15957 editmidi_dlg[7].dp = volume_str;
15958 editmidi_dlg[8].flags = loop?D_SELECTED:0;
15959 editmidi_dlg[10].flags =
15960 editmidi_dlg[11].flags =
15961 editmidi_dlg[12].flags =
15962 editmidi_dlg[13].flags = (data==NULL)?D_DISABLED:D_EXIT;
15963 editmidi_dlg[15].dp = start_str;
15964 editmidi_dlg[17].dp = loop_start_str;
15965 editmidi_dlg[19].dp = loop_end_str;
15966 editmidi_dlg[21].dp = pos_str;
15967 editmidi_dlg[23].dp = len_str;
15968 editmidi_dlg[25].dp = timestr(Midi_Info.len_sec);
15969 editmidi_dlg[26].flags = (flags&tfDISABLESAVE)?D_SELECTED:0;
15970
15971 popup_zqdialog_start();
15972 DIALOG_PLAYER *p = init_dialog(editmidi_dlg,-1);
15973
15974 while(update_dialog(p))
15975 {
15976 custom_vsync();
15977 // text_mode(vc(1));
15978 textprintf_ex(screen,get_zc_font(font_lfont_l),editmidi_dlg[0].x+int32_t(193*1.5),editmidi_dlg[0].y+int32_t(58*1.5),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%-5ld",midi_pos);
15979 }
15980
15981 ret = shutdown_dialog(p);
15982 popup_zqdialog_end();
15983
15984 loop = editmidi_dlg[8].flags?1:0;
15985 volume = vbound(atoi(volume_str),0,255); // Allegro can't play louder than 255.
15986
15987 start = vbound(atol(start_str),0,zc_max(Midi_Info.len_beats-4,0));
15988 loop_start = vbound(atol(loop_start_str),-1,zc_max(Midi_Info.len_beats-4,-1));
15989 loop_end = vbound(atol(loop_end_str),-1,Midi_Info.len_beats);
15990
15991 if(loop_end>0)
15992 {
15993 loop_end = vbound(loop_end,zc_max(loop_start+4,start+4),Midi_Info.len_beats);
15994 }
15995
15996 flags = 0;
15997 flags |= editmidi_dlg[26].flags&D_SELECTED?tfDISABLESAVE:0;
15998
15999 switch(ret)
16000 {
16001 case 9:
16002 if(getname("Load tune","mid;nsf",NULL,temppath,true))
16003 {
16004 zc_stop_midi();
16005
16006 if(data!=NULL && data!=customtunes[i].data)
16007 {
16008 destroy_midi((MIDI*)data);
16009 }
16010
16011 packfile_password("");
16012
16013 if((data=load_midi(temppath))==NULL)
16014 {
16015 jwin_alert("Error","Error loading tune:",temppath,NULL,"Dang",NULL,13,27,get_zc_font(font_lfont));
16016 }
16017 else
16018 {
16019 char *t = get_filename(temppath);
16020 int32_t j;
16021
16022 for(j=0; j<35 && t[j]!=0 && t[j]!='.'; j++)
16023 {
16024 title[j]=t[j];
16025 }
16026
16027 title[j]=0;
16028 }
16029
16030 get_midi_info((MIDI*)data,&Midi_Info);
16031 }
16032
16033 break;
16034
16035 case 10:
16036 zc_stop_midi();
16037 break;
16038
16039 case 12:
16040 if(midi_pos>0)
16041 {
16042 int32_t pos=midi_pos;
16043 zc_stop_midi();
16044 midi_loop_start = -1;
16045 midi_loop_end = -1;
16046 zc_play_midi((MIDI*)data,loop);
16047 zc_set_volume(-1,volume);
16048 midi_loop_start = loop_start;
16049 midi_loop_end = loop_end;
16050
16051 if(midi_loop_end<=0)
16052 {
16053 pos = zc_min(pos+16,Midi_Info.len_beats);
16054 }
16055 else
16056 {
16057 pos = zc_min(pos+16,midi_loop_end);
16058 }
16059
16060 if(pos>0)
16061 {
16062 zc_midi_seek(pos);
16063 }
16064
16065 break;
16066 }
16067
16068 // else play it...
16069
16070 case 13:
16071 if(midi_pos>0)
16072 {
16073 int32_t pos=midi_pos;
16074 zc_stop_midi();
16075 midi_loop_end = -1;
16076 midi_loop_start = -1;
16077 zc_play_midi((MIDI*)data,loop);
16078 zc_set_volume(-1,volume);
16079 midi_loop_end = loop_end;
16080 midi_loop_start = loop_start;
16081
16082 if(midi_loop_end<0)
16083 {
16084 pos = zc_min(pos+64,Midi_Info.len_beats);
16085 }
16086
16087 else
16088 {
16089 pos = zc_min(pos+64,midi_loop_end);
16090 }
16091
16092 if(pos>0)
16093 {
16094 zc_midi_seek(pos);
16095 }
16096
16097 break;
16098 }
16099
16100 // else play it...
16101
16102 case 11:
16103 {
16104 int32_t pos=midi_pos;
16105 zc_stop_midi();
16106 midi_loop_start = -1;
16107 midi_loop_end = -1;
16108 zc_play_midi((MIDI*)data,loop);
16109 zc_set_volume(-1,volume);
16110 zc_midi_seek(pos<0?start:pos);
16111 midi_loop_start = loop_start;
16112 midi_loop_end = loop_end;
16113 }
16114 break;
16115 }
16116 }
16117 while(ret<26&&ret!=0);
16118
16119 zc_stop_midi();
16120
16121 if(ret==27)
16122 {
16123 strcpy(customtunes[i].title,title);
16124 customtunes[i].volume = volume;
16125 customtunes[i].loop = loop;
16126 customtunes[i].start = start;
16127 customtunes[i].loop_start = loop_start;
16128 customtunes[i].loop_end = loop_end;
16129 customtunes[i].format = MFORMAT_MIDI;
16130 customtunes[i].flags = flags;
16131
16132 if(data!=customtunes[i].data)
16133 {
16134 if(customtunes[i].data)
16135 destroy_midi((MIDI*)customtunes[i].data);
16136
16137 customtunes[i].data = data;
16138 }
16139
16140 saved=false;
16141 }
16142
16143 if((ret==28||ret==0) && data!=customtunes[i].data)
16144 {
16145 if(data)
16146 {
16147 destroy_midi((MIDI*)data);
16148 }
16149 }
16150 }
16151
16152 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
16153 {
16154 if(msg==MSG_DRAW)
16155 {
16156 int32_t i = d->d1;
16157 int32_t x = d->x+d->w+8;
16158 int32_t y = d->y+4;
16159 int lh = text_height(font);
16160 char const* strs[] = {
16161 "Volume:",
16162 "Loop:",
16163 "Start:",
16164 "Loop Start:",
16165 "Loop End:"
16166 };
16167 int tw = 0;
16168 for(auto str : strs)
16169 {
16170 int w = text_length(font,str);
16171 if(w > tw)
16172 tw = w;
16173 }
16174 int tx = x+tw;
16175 for(int q = 0; q < 5; ++q)
16176 {
16177 textout_right_ex(screen,font,strs[q],tx,y+13+(lh*q),jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
16178 }
16179
16180 textprintf_ex(screen,font,tx+5,y+13+(lh*0),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%-3d",customtunes[i].volume);
16181 textprintf_ex(screen,font,tx+5,y+13+(lh*1),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%s",customtunes[i].loop?"On ":"Off");
16182 textprintf_ex(screen,font,tx+5,y+13+(lh*2),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%-5d",customtunes[i].start);
16183 textprintf_ex(screen,font,tx+5,y+13+(lh*3),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%-5d",customtunes[i].loop_start);
16184 textprintf_ex(screen,font,tx+5,y+13+(lh*4),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%-5d",customtunes[i].loop_end);
16185 }
16186
16187 return jwin_list_proc(msg,d,c);
16188 }
16189
16190 8 static ListData custommidi_list(custommidilist, &a4fonts[font_lfont_l]);
16191
16192 static DIALOG selectmidi_dlg[] =
16193 {
16194 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
16195 8 { jwin_win_proc, 24, 20, 273, 189, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Select music", NULL, NULL },
16196 8 { d_dummy_proc, 160, 56, 0, 8, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16197 8 { d_midilist_proc, 31, 44, 164, (1+16)*8, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &custommidi_list, NULL, NULL },
16198 // { jwin_droplist_proc, 72-12, 60+4, 161, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &tracknum_list, NULL, NULL },
16199 // { jwin_droplist_proc, 72-12, 60+4, 161, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &custommidi_list, NULL, NULL },
16200
16201 8 { jwin_button_proc, 90, 160+12+12, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Edit", NULL, NULL },
16202 8 { jwin_button_proc, 170, 160+12+12, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Done", NULL, NULL },
16203 8 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_DEL, (void *) close_dlg, NULL, NULL },
16204 8 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
16205 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
16206 };
16207
16208 int32_t onMidis()
16209 {
16210 stopMusic();
16211 int32_t ret;
16212 char buf[MIDI_TRACK_BUFFER_SIZE];
16213 number_list_size=MAXCUSTOMTUNES;
16214 number_list_zero=false;
16215 strcpy(temppath,midipath);
16216 selectmidi_dlg[0].dp2=get_zc_font(font_lfont);
16217
16218
16219 large_dialog(selectmidi_dlg);
16220
16221 selectmidi_dlg[2].dp2 = 0;
16222
16223 go();
16224 ret=do_zqdialog(selectmidi_dlg,2);
16225
16226 while(ret!=4&&ret!=0)
16227 {
16228 int32_t d=selectmidi_dlg[2].d1;
16229
16230 if(ret==5)
16231 {
16232 sprintf(buf,"Delete music %d?",d+1);
16233
16234 if(jwin_alert("Confirm Delete",buf,NULL,NULL,"&Yes","&No",'y','n',get_zc_font(font_lfont))==1)
16235 {
16236 customtunes[d].reset(); // reset_midi(customMIDIs+d);
16237 saved=false;
16238 }
16239 }
16240 else
16241 {
16242 edit_tune(d);
16243 }
16244
16245 ret=do_zqdialog(selectmidi_dlg,2);
16246 }
16247
16248 comeback();
16249 return D_O_K;
16250 }
16251
16252 /*******************************/
16253 /****** onEnhancedMusic ******/
16254 /*******************************/
16255
16256 static DIALOG editmusic_dlg[] =
16257 {
16258 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
16259 { jwin_win_proc, 24, 20, 273, 189, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Music Specs", NULL, NULL },
16260 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
16261 // 2
16262 { jwin_text_proc, 56, 94-16, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Music:", NULL, NULL },
16263 { jwin_text_proc, 104, 94-16, 48, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16264 { jwin_text_proc, 56, 114, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Name:", NULL, NULL },
16265 { jwin_edit_proc, 104, 114-4, 160, 16, vc(12), vc(1), 0, 0, 19, 0, NULL, NULL, NULL },
16266 { jwin_text_proc, 56, 124-4+12, 56, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Volume:", NULL, NULL },
16267 { jwin_edit_proc, 120, 124-4+12-4, 32, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
16268 // 8
16269 { jwin_check_proc, 176, 124+12-4, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, (void *) "Loop", NULL, NULL },
16270 // 9
16271 { jwin_button_proc, 50, 72-24, 57, 21, vc(14), vc(1), 'l', D_EXIT, 0, 0, (void *) "&Load", NULL, NULL },
16272 { jwin_iconbutton_proc, 116, 72-24, 33, 21, vc(14), vc(1), 0, D_EXIT, BTNICON_STOPSQUARE, 0, NULL, NULL, NULL },
16273 { jwin_iconbutton_proc, 156, 72-24, 33, 21, vc(14), vc(1), 0, D_EXIT, BTNICON_ARROW_RIGHT, 0, NULL, NULL, NULL },
16274 { jwin_iconbutton_proc, 196, 72-24, 33, 21, vc(14), vc(1), 0, D_EXIT, BTNICON_ARROW_RIGHT2, 0, NULL, NULL, NULL },
16275 { jwin_iconbutton_proc, 236, 72-24, 33, 21, vc(14), vc(1), 0, D_EXIT, BTNICON_ARROW_RIGHT3, 0, NULL, NULL, NULL },
16276 // 14
16277 { jwin_text_proc, 56, 134+4+12, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start:", NULL, NULL },
16278 { jwin_edit_proc, 112, 134+12, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16279 { jwin_text_proc, 176, 134+12+4, 56, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Loop Start:", NULL, NULL },
16280 { jwin_edit_proc, 240, 134+12, 40, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16281 { jwin_text_proc, 176, 144+12+12, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Loop End:", NULL, NULL },
16282 { jwin_edit_proc, 240, 144+12+12-4, 40, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16283 // 20
16284 { jwin_text_proc, 176, 94-16, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Position:", NULL, NULL },
16285 { jwin_text_proc, 217, 94-16, 32, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16286 { jwin_text_proc, 176, 104-8, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Length:", NULL, NULL },
16287 { jwin_text_proc, 216, 104-8, 32, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16288 { jwin_text_proc, 56, 104-8, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Time:", NULL, NULL },
16289 { jwin_text_proc, 104, 104-8, 32, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16290 // 26
16291 { jwin_button_proc, 90, 160+12+12, 61, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
16292 { jwin_button_proc, 170, 160+12+12, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
16293 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
16294 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
16295 };
16296
16297 int32_t d_musiclist_proc(int32_t msg,DIALOG *d,int32_t c)
16298 {
16299 return jwin_list_proc(msg,d,c);
16300 }
16301
16302 8 static ListData enhancedmusic_list(enhancedmusiclist, &font);
16303
16304 static DIALOG selectmusic_dlg[] =
16305 {
16306 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
16307 8 { jwin_win_proc, 24, 20, 273, 189, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Select Enhanced Music", NULL, NULL },
16308 8 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
16309 8 { d_musiclist_proc, 31, 44, 164, (1+16)*8, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &enhancedmusic_list, NULL, NULL },
16310 8 { jwin_button_proc, 90, 160+12+12, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Edit", NULL, NULL },
16311 8 { jwin_button_proc, 170, 160+12+12, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Done", NULL, NULL },
16312 8 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_DEL, (void *) close_dlg, NULL, NULL },
16313 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
16314 };
16315
16316 int32_t onEnhancedMusic()
16317 {
16318 // to be taken out - the custom music can all be found in one place
16319 /*stopMusic();
16320 int32_t ret;
16321 char buf[40];
16322 number_list_size=MAXCUSTOMMIDIS;
16323 number_list_zero=false;
16324 strcpy(temppath,midipath);
16325 selectmusic_dlg[0].dp2=get_zc_font(font_lfont);
16326 go();
16327 ret=do_zqdialog(selectmusic_dlg,2);
16328 while(ret!=4&&ret!=0)
16329 {
16330 int32_t d=selectmusic_dlg[2].d1;
16331 if(ret==5)
16332 {
16333 sprintf(buf,"Delete MIDI %d?",d+1);
16334 if(jwin_alert("Confirm Delete",buf,NULL,NULL,"&Yes","&No",'y','n',get_zc_font(font_lfont))==1)
16335 {
16336 reset_midi(customMIDIs+d);
16337 saved=false;
16338 }
16339 }
16340 else
16341 {
16342 edit_midi(d);
16343 }
16344 ret=do_zqdialog(selectmusic_dlg,2);
16345 }
16346 comeback();
16347 */
16348 return D_O_K;
16349 }
16350
16351 /*******************************/
16352 /********** onWarp ***********/
16353 /*******************************/
16354
16355 const char *warptypelist(int32_t index, int32_t *list_size)
16356 {
16357 if(index>=0)
16358 {
16359 if(index>=MAXWARPTYPES)
16360 index=MAXWARPTYPES-1;
16361
16362 return warptype_string[index];
16363 }
16364
16365 *list_size=MAXWARPTYPES;
16366 // *list_size=6;
16367 return NULL;
16368 }
16369
16370 const char *warpeffectlist(int32_t index, int32_t *list_size)
16371 {
16372 if(index>=0)
16373 {
16374 if(index>=MAXWARPEFFECTS)
16375 index=MAXWARPEFFECTS-1;
16376
16377 return warpeffect_string[index];
16378 }
16379
16380 *list_size=MAXWARPEFFECTS;
16381 return NULL;
16382 }
16383
16384 static int32_t warp1_list[] =
16385 {
16386 2,3,4,5,6,7,8,9,10,11,12,13,53,54,63,67,-1
16387 };
16388
16389 static int32_t warp2_list[] =
16390 {
16391 17,18,19,20,21,22,23,24,25,26,27,28,55,56,64,68,-1
16392 };
16393
16394 static int32_t warp3_list[] =
16395 {
16396 29,30,31,32,33,34,35,36,37,38,39,40,57,58,65,69,-1
16397 };
16398
16399 static int32_t warp4_list[] =
16400 {
16401 41,42,43,44,45,46,47,48,49,50,51,52,59,60,66,70,-1
16402 };
16403
16404 static TABPANEL warp_tabs[] =
16405 {
16406 // (text)
16407 { (char *)"A", D_SELECTED, warp1_list, 0, NULL },
16408 { (char *)"B", 0, warp2_list, 0, NULL },
16409 { (char *)"C", 0, warp3_list, 0, NULL },
16410 { (char *)"D", 0, warp4_list, 0, NULL },
16411 { NULL, 0, NULL, 0, NULL }
16412 };
16413
16414 int32_t onTileWarpIndex(int32_t index)
16415 {
16416 int32_t i=-1;
16417
16418 while(warp_tabs[++i].text != NULL)
16419 warp_tabs[i].flags = (i==index ? D_SELECTED : 0);
16420
16421 onTileWarp();
16422 return D_O_K;
16423 }
16424
16425 static char warpr_buf[10];
16426 const char *warprlist(int32_t index, int32_t *list_size)
16427 {
16428 if(index>=0)
16429 {
16430 bound(index,0,3);
16431 sprintf(warpr_buf,"%c",index+0x41);
16432 return warpr_buf;
16433 }
16434
16435 *list_size=4;
16436 return NULL;
16437 }
16438
16439 int32_t d_wflag_proc(int32_t msg,DIALOG *d,int32_t c);
16440
16441 8 static ListData warp_dlg_list(warptypelist, &font);
16442 8 static ListData warp_ret_list(warprlist, &font);
16443
16444 int32_t d_warpdestscrsel_proc(int32_t msg,DIALOG *d,int32_t c)
16445 {
16446 if(msg == MSG_START)
16447 {
16448 d->d1 = -1; //cached val
16449 d->d2 = -1; //cached dmap
16450 d->fg = 0; //cached 'force_16'
16451 }
16452 char* buf = (char*)d->dp;
16453 vector<DIALOG*>* dlgs = (vector<DIALOG*>*)d->dp2;
16454 int* dmap_ptr = (int*) d->dp3;
16455 if(!(buf && dmap_ptr))
16456 return D_O_K;
16457 bool is_overworld = ((DMaps[*dmap_ptr].type&dmfTYPE)==dmOVERW);
16458 int scrw = is_overworld ? 16 : 8, scrh = 9;
16459 const int max = 0x87;
16460 int bufval = zc_xtoi(buf);
16461 int val = vbound(bufval,0,max);
16462 auto& dm = DMaps[*dmap_ptr];
16463 auto val_offset = dm.xoff < 0 ? -dm.xoff : 0;
16464 bool force_16 = d->fg;
16465 if(!is_overworld)
16466 {
16467 if((val&0xF) >= 0x8)
16468 force_16 = true;
16469 else if((val&0xF) < val_offset && (val&0xF0) < 0x80)
16470 force_16 = true;
16471 }
16472 if(force_16) //can't bound, some quests need to warp out of bounds... -Em
16473 {
16474 scrw = 16; //just force show the larger grid instead
16475 val_offset = 0;
16476 }
16477
16478 int xscl = d->w/scrw;
16479 int yscl = d->h/scrh;
16480
16481 int ret = D_O_K;
16482 bool redraw = false;
16483 if(d->d1 != val)
16484 {
16485 redraw = true;
16486 d->d1 = val;
16487 }
16488 if(bufval != val)
16489 {
16490 redraw = true;
16491 sprintf(buf, "%X", val);
16492 }
16493 if(d->d2 != *dmap_ptr)
16494 {
16495 redraw = true;
16496 d->d2 = *dmap_ptr;
16497 }
16498 switch(msg)
16499 {
16500 case MSG_WANTFOCUS:
16501 ret = D_WANTFOCUS;
16502 break;
16503 case MSG_CLICK:
16504 {
16505 d->fg = force_16 ? 1 : 0;
16506 bool redraw2 = false;
16507 while(gui_mouse_b())
16508 {
16509 if(redraw2)
16510 {
16511 broadcast_dialog_message(MSG_DRAW, 0);
16512 redraw2 = false;
16513 }
16514 if(!d->fg && (gui_mouse_b()&2))
16515 {
16516 scrw = 16;
16517 xscl = d->w/scrw;
16518 yscl = d->h/scrh;
16519 val_offset = 0;
16520 d->fg = 1;
16521 redraw2 = true;
16522 }
16523 custom_vsync();
16524 if(!mouse_in_rect(d->x,d->y,d->w,d->h))
16525 continue;
16526 int mx = gui_mouse_x()-d->x, my = gui_mouse_y()-d->y;
16527 int y = vbound(my/yscl,0,scrh-1);
16528 auto offs = y==8 ? 0 : val_offset;
16529 int x = vbound(mx/xscl,offs,scrw-1);
16530 auto val2 = (y*16)+x;
16531 if(val2 > max) //out of bounds in the bottom-right
16532 continue;
16533 val = val2;
16534 if(d->d1 != val)
16535 {
16536 d->d1 = val;
16537 sprintf(buf, "%02X", val);
16538 redraw2 = true;
16539 }
16540 }
16541 redraw = true;
16542 d->fg = 0;
16543 break;
16544 }
16545 case MSG_DRAW:
16546 {
16547 rectfill(screen,d->x,d->y,d->x+d->w-1,d->y+d->h-1,jwin_pal[jcBOX]);
16548 jwin_draw_frame(screen, d->x-2, d->y-2, d->w+4, d->h+4, FR_MENU);
16549 for(int yind = 0; yind < scrh; ++yind)
16550 {
16551 auto gr = (yind < 8 ? dm.grid[yind] : 0);
16552 for(int xind = (yind == 8 ? 0 : val_offset); xind < scrw; ++xind)
16553 {
16554 int scr = xind+(yind*16);
16555 if(scr > max)
16556 continue;
16557 int fr = FR_MENU;
16558 if(scr == d->d1)
16559 fr = FR_GREEN;
16560 else if(!is_overworld && xind < 8 && (gr&(1<<(8-xind-1))))
16561 fr = FR_MENU_INV;
16562 jwin_draw_frame(screen, d->x+(xind*xscl), d->y+(yind*yscl), xscl, yscl, fr);
16563 }
16564 }
16565 break;
16566 }
16567 case MSG_XCHAR:
16568 {
16569 bool on_80 = (val&0xF0) == 0x80;
16570 switch(c>>8)
16571 {
16572 case KEY_UP:
16573 if((val&0xF0) && !(val_offset && on_80 && (val&0xF) < val_offset))
16574 {
16575 val -= 0x10;
16576 redraw = true;
16577 }
16578 ret |= D_USED_CHAR;
16579 break;
16580 case KEY_DOWN:
16581 if((val&0xF0) < ((val&0xF) < 0x8 ? 0x80 : 0x70))
16582 {
16583 val += 0x10;
16584 redraw = true;
16585 }
16586 ret |= D_USED_CHAR;
16587 break;
16588 case KEY_LEFT:
16589 if((val&0xF) > (on_80 ? 0 : val_offset))
16590 {
16591 --val;
16592 redraw = true;
16593 }
16594 ret |= D_USED_CHAR;
16595 break;
16596 case KEY_RIGHT:
16597 if((val&0xF) < scrw-1 && val < 0x87)
16598 {
16599 ++val;
16600 redraw = true;
16601 }
16602 ret |= D_USED_CHAR;
16603 break;
16604 }
16605 if(redraw)
16606 sprintf(buf, "%02X", val);
16607 break;
16608 }
16609 }
16610 if(redraw)
16611 {
16612 if(msg == MSG_IDLE)
16613 broadcast_dialog_message(MSG_DRAW,0);
16614 else
16615 {
16616 d->d1 = d->d2 = -1;
16617 object_message(d,MSG_IDLE,0);
16618 }
16619 }
16620
16621 return ret;
16622 }
16623
16624 int32_t tilewarpdmapxy[6] = {170,38,170,18,170,27};
16625 static DIALOG tilewarp_dlg[] =
16626 {
16627 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
16628 8 { jwin_win_proc, 0, 0, 302, 178, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
16629 8 { jwin_rtext_proc, 89, 43, 40, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Type:", NULL, NULL },
16630 8 { jwin_rtext_proc, 57, 62, 40, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
16631 8 { jwin_rtext_proc, 57, 80, 64, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Screen: 0x", NULL, NULL },
16632 8 { jwin_droplist_proc, 91, 38, 193, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &warp_dlg_list, NULL, NULL },
16633 //5
16634 8 { d_dropdmaplist_proc, 59, 57, 225, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &dmap_list, NULL, tilewarpdmapxy },
16635 8 { jwin_hexedit_proc, 59, 76, 24, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
16636 8 { jwin_button_proc, 61, 152, 41, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
16637 8 { jwin_button_proc, 121, 152, 41, 21, vc(14), vc(1), 'g', D_EXIT, 0, 0, (void *) "&Go", NULL, NULL },
16638 8 { jwin_button_proc, 181, 152, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
16639 //10
16640 8 { jwin_rtext_proc, 82, 95, 100, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Use Warp Return:", NULL, NULL },
16641 8 { jwin_droplist_proc, 10, 105, 72, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &warp_ret_list, NULL, NULL },
16642 8 { jwin_check_proc, 10, 125, 129, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Combos Carry Over", NULL, NULL },
16643 8 { d_warpdestscrsel_proc, 90, 76, 8*16, 8*9, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
16644 8 { jwin_button_proc, 59, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "A", NULL, NULL },
16645 //15
16646 8 { jwin_button_proc, 109, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "B", NULL, NULL },
16647 8 { jwin_button_proc, 159, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "C", NULL, NULL },
16648 8 { jwin_button_proc, 209, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "D", NULL, NULL },
16649 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
16650 };
16651
16652 int32_t sidewarpdmapxy[6] = {170,38,170,18,170,27};
16653 static DIALOG sidewarp_dlg[] =
16654 {
16655 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
16656 8 { jwin_win_proc, 0, 0, 302, 178, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
16657 8 { jwin_rtext_proc, 89, 43, 40, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Type:", NULL, NULL },
16658 8 { jwin_rtext_proc, 57, 62, 40, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
16659 8 { jwin_rtext_proc, 57, 80, 64, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Screen: 0x", NULL, NULL },
16660 8 { jwin_droplist_proc, 91, 38, 193, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &warp_dlg_list, NULL, NULL },
16661 //5
16662 8 { d_dropdmaplist_proc, 59, 57, 225, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &dmap_list, NULL, tilewarpdmapxy },
16663 8 { jwin_hexedit_proc, 59, 76, 24, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
16664 8 { jwin_button_proc, 61, 152, 41, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
16665 8 { jwin_button_proc, 121, 152, 41, 21, vc(14), vc(1), 'g', D_EXIT, 0, 0, (void *) "&Go", NULL, NULL },
16666 8 { jwin_button_proc, 181, 152, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
16667 //10
16668 8 { jwin_rtext_proc, 82, 95, 100, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Use Warp Return:", NULL, NULL },
16669 8 { jwin_droplist_proc, 10, 105, 72, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &warp_ret_list, NULL, NULL },
16670 8 { jwin_check_proc, 10, 125, 129, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Combos Carry Over", NULL, NULL },
16671 8 { d_warpdestscrsel_proc, 90, 76, 8*16, 8*9, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
16672 8 { jwin_button_proc, 59, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "A", NULL, NULL },
16673 //15
16674 8 { jwin_button_proc, 109, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "B", NULL, NULL },
16675 8 { jwin_button_proc, 159, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "C", NULL, NULL },
16676 8 { jwin_button_proc, 209, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "D", NULL, NULL },
16677 // 18
16678 8 { d_wflag_proc, 18, 17, 15, 8, vc(4), vc(0), 0, 0, 1, 0, NULL, NULL, NULL },
16679 8 { d_wflag_proc, 18, 47, 15, 8, vc(4), vc(0), 0, 0, 1, 0, NULL, NULL, NULL },
16680 // 20
16681 8 { d_wflag_proc, 8, 27, 8, 15, vc(4), vc(0), 0, 0, 1, 0, NULL, NULL, NULL },
16682 8 { d_wflag_proc, 37, 27, 8, 15, vc(4), vc(0), 0, 0, 1, 0, NULL, NULL, NULL },
16683
16684 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
16685 };
16686
16687 int32_t warpringxy[6] = {170,38,170,18,170,27};
16688 static DIALOG warpring_warp_dlg[] =
16689 {
16690 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
16691 8 { jwin_win_proc, 0, 0, 302, 145, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
16692 8 { jwin_rtext_proc, 57, 25, 40, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
16693 8 { jwin_rtext_proc, 57, 46, 64, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Screen: 0x", NULL, NULL },
16694 8 { d_dropdmaplist_proc, 59, 19, 225, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &dmap_list, NULL, warpringxy },
16695 8 { jwin_hexedit_proc, 59, 39, 24, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
16696 // 5
16697 8 { jwin_button_proc, 61, 115, 41, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
16698 8 { jwin_button_proc, 121, 115, 41, 21, vc(14), vc(1), 'g', D_EXIT, 0, 0, (void *) "&Go", NULL, NULL },
16699 8 { jwin_button_proc, 181, 115, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
16700 8 { d_warpdestscrsel_proc, 90, 39, 8*16, 8*9, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
16701
16702 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
16703 };
16704
16705 // Side warp flag procedure
16706 int32_t d_wflag_proc(int32_t msg,DIALOG *d,int32_t)
16707 {
16708 int32_t ret = D_O_K;
16709 switch(msg)
16710 {
16711 case MSG_DRAW:
16712 {
16713 int32_t c2=(d->flags&D_SELECTED)?d->fg:d->bg;
16714
16715 if(d->d1==1)
16716 {
16717 jwin_draw_frame(screen,d->x,d->y,d->w,d->h, FR_DEEP);
16718 rectfill(screen,d->x+2, d->y+2, d->x+d->w-3, d->y+d->h-3,c2);
16719
16720 if(d->flags&D_SELECTED)
16721 {
16722 int32_t e=d->d2&3;
16723
16724 if(d->w>d->h)
16725 textprintf_centre_ex(screen,get_zc_font(font_lfont_l), d->x+(d->w/2),d->y,jwin_pal[jcBOXFG],-1,"%c",e+0x41);
16726 else
16727 textprintf_centre_ex(screen,get_zc_font(font_lfont_l), d->x+(d->w/2),d->y+(d->h/2)-4,jwin_pal[jcBOXFG],-1,"%c",e+0x41);
16728 }
16729
16730 }
16731 else
16732 {
16733 rectfill(screen,d->x, d->y, d->x+d->w-1, d->y+d->h-1,c2);
16734 }
16735 }
16736 break;
16737
16738 case MSG_CLICK:
16739 {
16740 if(d->flags & D_DISABLED)
16741 return D_O_K;
16742 bool rclick = gui_mouse_b() & 2;
16743 if(d->d1==1)
16744 {
16745 if(!(d->flags&D_SELECTED))
16746 {
16747 d->flags |= D_SELECTED;
16748 d->d2 &= 0x80;
16749 if (rclick)
16750 d->d2 |= 3;
16751 }
16752 else
16753 {
16754 if((d->d2&3) == (rclick?0:3))
16755 {
16756 d->flags ^= D_SELECTED;
16757 d->d2 &= 0x80;
16758 }
16759 else
16760 {
16761 int32_t f = d->d2&3;
16762 d->d2 &= 0x80;
16763 f += rclick ? -1 : 1;
16764 d->d2 |= f;
16765 }
16766 }
16767 }
16768 else
16769 {
16770 d->flags^=D_SELECTED;
16771 }
16772
16773 int32_t c2=(d->flags&D_SELECTED)?d->fg:d->bg;
16774
16775 if(d->d1==1)
16776 {
16777 jwin_draw_frame(screen,d->x,d->y,d->w,d->h, FR_DEEP);
16778 rectfill(screen,d->x+2, d->y+2, d->x+d->w-3, d->y+d->h-3,c2);
16779
16780 if(d->flags&D_SELECTED)
16781 {
16782 int32_t e=d->d2&3;
16783
16784 if(d->w>d->h)
16785 textprintf_centre_ex(screen,get_zc_font(font_lfont_l),d->x+(d->w/2),d->y,jwin_pal[jcBOXFG],-1,"%c",e+0x41);
16786 else
16787 textprintf_centre_ex(screen,get_zc_font(font_lfont_l),d->x+(d->w/2),d->y+(d->h/2)-4,jwin_pal[jcBOXFG],-1,"%c",e+0x41);
16788 }
16789 }
16790 else
16791 {
16792 rectfill(screen,d->x, d->y, d->x+d->w-1, d->y+d->h-1,c2);
16793 }
16794
16795
16796 while(gui_mouse_b())
16797 {
16798 /* do nothing */
16799 rest(1);
16800 }
16801 ret = D_REDRAWME;
16802 }
16803 break;
16804 }
16805
16806 return ret;
16807 }
16808
16809 int32_t d_dmapscrsel_proc(int32_t msg,DIALOG *d,int32_t c)
16810 {
16811 //these are here to bypass compiler warnings about unused arguments
16812 c=c;
16813
16814 int32_t ret = D_O_K;
16815
16816 switch(msg)
16817 {
16818 case MSG_CLICK:
16819 sprintf((char*)((d+2)->dp),"%X%X",vbound((gui_mouse_y()-d->y)/4,0,7),vbound((gui_mouse_x()-d->x)/(((DMaps[(d-1)->d1].type&dmfTYPE)==1)?4:8),0,(((DMaps[(d-1)->d1].type&dmfTYPE)==1)?15:7)));
16820 object_message(d+2, MSG_DRAW, 0);
16821 break;
16822 }
16823
16824 return ret;
16825 }
16826
16827 int32_t warpdestsel_x=-1;
16828 int32_t warpdestsel_y=-1;
16829 int32_t warpdestmap=-1;
16830 int32_t warpdestscr=-1;
16831
16832 int32_t jwin_minibutton_proc(int32_t msg,DIALOG *d,int32_t c)
16833 {
16834 switch(msg)
16835 {
16836 case MSG_DRAW:
16837 jwin_draw_text_button(screen, d->x, d->y, d->w, d->h, (char*)d->dp, d->flags, false);
16838 return D_O_K;
16839 break;
16840 }
16841
16842 return jwin_button_proc(msg,d,c);
16843 }
16844
16845 int32_t d_triggerbutton_proc(int32_t msg,DIALOG *d,int32_t c)
16846 {
16847 static BITMAP *dummy=create_bitmap_ex(8, 1, 1);
16848
16849 switch(msg)
16850 {
16851 case MSG_START:
16852 d->w=gui_textout_ln(dummy, font, (uint8_t *)d->dp, 0, 0, jwin_pal[jcMEDDARK], -1, 0)+4;
16853 d->h=text_height(font)+5;
16854 break;
16855
16856 case MSG_GOTFOCUS:
16857 d->flags&=~D_GOTFOCUS;
16858 break;
16859
16860 }
16861
16862 return jwin_minibutton_proc(msg,d,c);
16863 }
16864
16865 int32_t d_alltriggerbutton_proc(int32_t msg,DIALOG *d,int32_t c)
16866 {
16867 DIALOG *temp_d;
16868 int32_t ret=d_triggerbutton_proc(msg,d,c);
16869
16870 switch(msg)
16871 {
16872 case MSG_CLICK:
16873 temp_d=d-1;
16874
16875 while(temp_d->proc==d_triggerbutton_proc)
16876 {
16877 temp_d->flags&=~D_SELECTED;
16878 temp_d->flags|=D_DIRTY;
16879
16880 if(d->flags&D_SELECTED)
16881 {
16882 temp_d->flags|=D_SELECTED;
16883 }
16884
16885 --temp_d;
16886 }
16887
16888 break;
16889 }
16890
16891 return ret;
16892 }
16893
16894 int32_t d_ticsedit_proc(int32_t msg,DIALOG *d,int32_t c)
16895 {
16896 int32_t ret = jwin_edit_proc(msg,d,c);
16897
16898 if(msg==MSG_DRAW)
16899 {
16900 int32_t tics=vbound(atoi((char*)d->dp),0,65535);
16901 sprintf((char*)(d+1)->dp,"%s %s",ticksstr(tics),tics==0?"(No Timed Warp)":" ");
16902 object_message(d+1,MSG_DRAW,c);
16903 }
16904
16905 return ret;
16906 }
16907
16908 8 static ListData warp_effect_list(warpeffectlist,&font);
16909
16910 struct tw_data
16911 {
16912 int twscr[4], twtype[4], twdmap[4], wret[4];
16913 byte oflags;
16914 optional<uint> loaded;
16915
16916 tw_data(mapscr* scr) {load_scr(scr);}
16917 void load_scr(mapscr* scr)
16918 {
16919 oflags = scr->tilewarpoverlayflags;
16920 for(int q = 0; q < 4; ++q)
16921 {
16922 twscr[q] = scr->tilewarpscr[q];
16923 twtype[q] = scr->tilewarptype[q];
16924 twdmap[q] = scr->tilewarpdmap[q];
16925 wret[q] = (scr->warpreturnc >> (2*q))&3;
16926 }
16927 loaded.reset();
16928 }
16929 void save_scr(mapscr* scr)
16930 {
16931 saved=false;
16932 scr->tilewarpoverlayflags = oflags;
16933 scr->warpreturnc = scr->warpreturnc & 0xFF00;
16934 for(int q = 0; q < 4; ++q)
16935 {
16936 scr->tilewarpscr[q] = twscr[q];
16937 scr->tilewarptype[q] = twtype[q];
16938 scr->tilewarpdmap[q] = twdmap[q];
16939 scr->warpreturnc |= wret[q] << (2*q);
16940 }
16941 }
16942
16943 void load(uint ind)
16944 {
16945 if(ind >= 4) return;
16946 loaded = ind;
16947 tilewarp_dlg[4].d1 = twtype[ind];
16948 tilewarp_dlg[5].d1 = twdmap[ind];
16949 char* buf = (char*)tilewarp_dlg[6].dp;
16950 sprintf(buf,"%02X",twscr[ind]);
16951 tilewarp_dlg[11].d1 = wret[ind];
16952 SETFLAG(tilewarp_dlg[12].flags, D_SELECTED, get_bit(&oflags,ind));
16953 for(int q = 0; q < 4; ++q)
16954 SETFLAG(tilewarp_dlg[14+q].flags,(D_SELECTED|D_DISABLED),q==ind);
16955 }
16956 void save(uint ind)
16957 {
16958 if(ind >= 4) return;
16959 twtype[ind] = tilewarp_dlg[4].d1;
16960 twdmap[ind] = tilewarp_dlg[5].d1;
16961 char* buf = (char*)tilewarp_dlg[6].dp;
16962 twscr[ind] = vbound(zc_xtoi(buf),0x00,0x87);
16963 wret[ind] = tilewarp_dlg[11].d1;
16964 set_bit(&oflags, ind, tilewarp_dlg[12].flags & D_SELECTED);
16965 }
16966 void save()
16967 {
16968 if(loaded)
16969 save(*loaded);
16970 }
16971 void swap(uint ind)
16972 {
16973 if(ind >= 4) return;
16974 if(loaded)
16975 {
16976 save(*loaded);
16977 if(*loaded == ind)
16978 return;
16979 }
16980 load(ind);
16981 }
16982 };
16983 int32_t onTileWarp()
16984 {
16985 restore_mouse();
16986 tilewarp_dlg[0].dp=(void *) "Tile Warp";
16987 tilewarp_dlg[0].dp2=get_zc_font(font_lfont);
16988
16989 mapscr* mptr = Map.CurrScr();
16990 char buf[10];
16991 tilewarp_dlg[6].dp=buf;
16992 tilewarp_dlg[13].dp = buf;
16993 tilewarp_dlg[13].dp3 = &tilewarp_dlg[5].d1;
16994
16995 vector<DIALOG*> dlgs;
16996 dlgs.push_back(&tilewarp_dlg[5]);
16997 dlgs.push_back(&tilewarp_dlg[6]);
16998 tilewarp_dlg[13].dp2 = &dlgs;
16999
17000 tw_data data(mptr);
17001 data.load(0);
17002
17003 dmap_list_size=MAXDMAPS;
17004 dmap_list_zero=true;
17005
17006 large_dialog(tilewarp_dlg);
17007
17008 bool running = true;
17009 int ret;
17010 do
17011 {
17012 ret = do_zqdialog(tilewarp_dlg,-1);
17013 switch(ret)
17014 {
17015 // OK, GO
17016 case 7: case 8:
17017 running = false;
17018 data.save();
17019 data.save_scr(mptr);
17020 refresh(rMENU);
17021 break;
17022 //Cancel
17023 case 9:
17024 running = false;
17025 break;
17026 //A,B,C,D
17027 case 14: case 15: case 16: case 17:
17028 data.swap(ret-14);
17029 break;
17030 }
17031 }
17032 while(running);
17033
17034 if(ret==8) //GO
17035 {
17036 int32_t index = *data.loaded;
17037
17038 FlashWarpSquare = -1;
17039 int32_t tm = Map.getCurrMap();
17040 int32_t ts = Map.getCurrScr();
17041 int32_t thistype = mptr->tilewarptype[index];
17042 Map.dowarp(0,index);
17043
17044 if((ts!=Map.getCurrScr() || tm!=Map.getCurrMap()) && thistype != wtCAVE && thistype != wtSCROLL)
17045 {
17046 FlashWarpSquare = (TheMaps[tm*MAPSCRS+ts].warpreturnc>>(index*2))&3;
17047 FlashWarpClk = 32;
17048 }
17049
17050 refresh(rALL);
17051 }
17052
17053 return D_O_K;
17054 }
17055
17056 struct sw_data
17057 {
17058 int swscr[4], swtype[4], swdmap[4], wret[4];
17059 byte oflags;
17060 optional<uint> loaded;
17061
17062 sw_data(mapscr* scr) {load_scr(scr);}
17063 void load_scr(mapscr* scr)
17064 {
17065 oflags = scr->sidewarpoverlayflags;
17066 for(int q = 0; q < 4; ++q)
17067 {
17068 swscr[q] = scr->sidewarpscr[q];
17069 swtype[q] = scr->sidewarptype[q];
17070 swdmap[q] = scr->sidewarpdmap[q];
17071 wret[q] = (scr->warpreturnc >> (2*(q+4)))&3;
17072 }
17073 loaded.reset();
17074
17075 for(int32_t i=0; i<4; i++)
17076 {
17077 sidewarp_dlg[18+i].d2 = 0x80;
17078 if(scr->flags2&(1<<i))
17079 {
17080 sidewarp_dlg[18+i].flags = D_SELECTED ;
17081 sidewarp_dlg[18+i].d2 |= (scr->sidewarpindex>>(2*i))&3;
17082 }
17083 else
17084 {
17085 sidewarp_dlg[18+i].flags = 0;
17086 }
17087 }
17088 }
17089 void save_scr(mapscr* scr)
17090 {
17091 saved=false;
17092 scr->sidewarpoverlayflags = oflags;
17093 scr->warpreturnc = scr->warpreturnc & 0x00FF;
17094 for(int q = 0; q < 4; ++q)
17095 {
17096 scr->sidewarpscr[q] = swscr[q];
17097 scr->sidewarptype[q] = swtype[q];
17098 scr->sidewarpdmap[q] = swdmap[q];
17099 scr->warpreturnc |= wret[q] << (2*(q+4));
17100 }
17101
17102 scr->flags2 &= ~0xF;
17103 scr->sidewarpindex = 0;
17104 for(int32_t i=0; i<4; i++)
17105 {
17106 if(sidewarp_dlg[18+i].flags & D_SELECTED)
17107 scr->flags2 |= 1<<i;
17108 scr->sidewarpindex |= (sidewarp_dlg[18+i].d2&3) << (i*2);
17109 }
17110 }
17111
17112 void load(uint ind)
17113 {
17114 if(ind >= 4) return;
17115 loaded = ind;
17116 sidewarp_dlg[4].d1 = swtype[ind];
17117 sidewarp_dlg[5].d1 = swdmap[ind];
17118 char* buf = (char*)sidewarp_dlg[6].dp;
17119 sprintf(buf,"%02X",swscr[ind]);
17120 sidewarp_dlg[11].d1 = wret[ind];
17121 SETFLAG(sidewarp_dlg[12].flags, D_SELECTED, get_bit(&oflags,ind));
17122 for(int q = 0; q < 4; ++q)
17123 SETFLAG(sidewarp_dlg[14+q].flags,(D_SELECTED|D_DISABLED),q==ind);
17124 }
17125 void save(uint ind)
17126 {
17127 if(ind >= 4) return;
17128 swtype[ind] = sidewarp_dlg[4].d1;
17129 swdmap[ind] = sidewarp_dlg[5].d1;
17130 char* buf = (char*)sidewarp_dlg[6].dp;
17131 swscr[ind] = vbound(zc_xtoi(buf),0x00,0x87);
17132 wret[ind] = sidewarp_dlg[11].d1;
17133 set_bit(&oflags, ind, sidewarp_dlg[12].flags & D_SELECTED);
17134 }
17135 void save()
17136 {
17137 if(loaded)
17138 save(*loaded);
17139 }
17140 void swap(uint ind)
17141 {
17142 if(ind >= 4) return;
17143 if(loaded)
17144 {
17145 save(*loaded);
17146 if(*loaded == ind)
17147 return;
17148 }
17149 load(ind);
17150 }
17151 };
17152 int32_t onSideWarp()
17153 {
17154 restore_mouse();
17155 sidewarp_dlg[0].dp=(void *) "Side Warp";
17156 sidewarp_dlg[0].dp2=get_zc_font(font_lfont);
17157
17158 mapscr* mptr = Map.CurrScr();
17159 char buf[10];
17160 sidewarp_dlg[6].dp=buf;
17161 sidewarp_dlg[13].dp = buf;
17162 sidewarp_dlg[13].dp3 = &sidewarp_dlg[5].d1;
17163
17164 vector<DIALOG*> dlgs;
17165 dlgs.push_back(&sidewarp_dlg[5]);
17166 dlgs.push_back(&sidewarp_dlg[6]);
17167 sidewarp_dlg[13].dp2 = &dlgs;
17168
17169 sw_data data(mptr);
17170 data.load(0);
17171
17172 dmap_list_size=MAXDMAPS;
17173 dmap_list_zero=true;
17174
17175 large_dialog(sidewarp_dlg);
17176
17177 bool running = true;
17178 int ret;
17179 do
17180 {
17181 ret = do_zqdialog(sidewarp_dlg,-1);
17182 switch(ret)
17183 {
17184 // OK, GO
17185 case 7: case 8:
17186 running = false;
17187 data.save();
17188 data.save_scr(mptr);
17189 refresh(rMENU);
17190 break;
17191 //Cancel
17192 case 9:
17193 running = false;
17194 break;
17195 //A,B,C,D
17196 case 14: case 15: case 16: case 17:
17197 data.swap(ret-14);
17198 break;
17199 }
17200 }
17201 while(running);
17202
17203 if(ret==8) //GO
17204 {
17205 int32_t index = *data.loaded;
17206
17207 FlashWarpSquare = -1;
17208 int32_t tm = Map.getCurrMap();
17209 int32_t ts = Map.getCurrScr();
17210
17211 int32_t thistype = mptr->sidewarptype[index];
17212 Map.dowarp(1,index);
17213
17214 if((ts!=Map.getCurrScr() || tm!=Map.getCurrMap()) && thistype != wtSCROLL)
17215 {
17216 FlashWarpSquare = (TheMaps[tm*MAPSCRS+ts].warpreturnc>>(8+index*2))&3;
17217 FlashWarpClk = 0x20;
17218 }
17219
17220 refresh(rALL);
17221 }
17222
17223 return D_O_K;
17224 }
17225
17226
17227
17228 const char *dirlist(int32_t index, int32_t *list_size)
17229 {
17230 if(index>=0)
17231 {
17232 if(index>3)
17233 index=3;
17234
17235 return mazedirstr[index];
17236 }
17237
17238 *list_size=4;
17239 return NULL;
17240 }
17241
17242 8 static ListData path_dlg_list(dirlist, &font);
17243
17244 static DIALOG path_dlg[] =
17245 {
17246 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
17247 8 { jwin_win_proc, 80, 57, 161, 164, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Maze Path", NULL, NULL },
17248 8 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
17249 8 { jwin_text_proc, 94, 106, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "1st", NULL, NULL },
17250 8 { jwin_text_proc, 94, 124, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "2nd", NULL, NULL },
17251 8 { jwin_text_proc, 94, 142, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "3rd", NULL, NULL },
17252 8 { jwin_text_proc, 94, 160, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "4th", NULL, NULL },
17253 8 { jwin_text_proc, 94, 178, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Exit", NULL, NULL },
17254 8 { jwin_droplist_proc, 140, 102, 80+1, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &path_dlg_list, NULL, NULL },
17255 8 { jwin_droplist_proc, 140, 120, 80+1, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &path_dlg_list, NULL, NULL },
17256 8 { jwin_droplist_proc, 140, 138, 80+1, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &path_dlg_list, NULL, NULL },
17257 8 { jwin_droplist_proc, 140, 156, 80+1, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &path_dlg_list, NULL, NULL },
17258 8 { jwin_droplist_proc, 140, 174, 80+1, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &path_dlg_list, NULL, NULL },
17259 8 { jwin_button_proc, 90, 194, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
17260 8 { jwin_button_proc, 170, 194, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
17261 8 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
17262 8 { jwin_text_proc, 87, 82, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "A Lost Woods-style maze screen", NULL, NULL },
17263 8 { jwin_text_proc, 87, 92, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "with a normal and secret exit.", NULL, NULL },
17264 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
17265 };
17266
17267 int32_t onPath()
17268 {
17269 restore_mouse();
17270 path_dlg[0].dp2=get_zc_font(font_lfont);
17271
17272 for(int32_t i=0; i<4; i++)
17273 path_dlg[i+7].d1 = Map.CurrScr()->path[i];
17274
17275 path_dlg[11].d1 = Map.CurrScr()->exitdir;
17276
17277 large_dialog(path_dlg);
17278
17279 int32_t ret;
17280
17281 do
17282 {
17283 ret=do_zqdialog(path_dlg,7);
17284
17285 if(ret==12) for(int32_t i=0; i<4; i++)
17286 {
17287 if(path_dlg[i+7].d1 == path_dlg[11].d1)
17288 {
17289 if(jwin_alert("Exit Problem","One of the path's directions is","also the normal Exit direction! Continue?",NULL,"Yes","No",'y','n',get_zc_font(font_lfont))==2)
17290 ret = -1;
17291
17292 break;
17293 }
17294 }
17295 }
17296 while(ret == -1);
17297
17298 if(ret==12)
17299 {
17300 saved=false;
17301
17302 for(int32_t i=0; i<4; i++)
17303 Map.CurrScr()->path[i] = path_dlg[i+7].d1;
17304
17305 Map.CurrScr()->exitdir = path_dlg[11].d1;
17306
17307 if(!(Map.CurrScr()->flags&fMAZE))
17308 if(jwin_alert("Screen Flag","Turn on the 'Use Maze Path' Screen Flag?","(Go to 'Screen Data' to turn it off.)",NULL,"Yes","No",'y','n',get_zc_font(font_lfont))==1)
17309 Map.CurrScr()->flags |= fMAZE;
17310 }
17311
17312 refresh(rMAP+rMENU);
17313 return D_O_K;
17314 }
17315
17316
17317
17318 static DIALOG editinfo_dlg[] =
17319 {
17320 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
17321 8 { jwin_win_proc, 0, 10, 208, 204, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
17322 8 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
17323 8 { jwin_text_proc, 24, 60, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "1st", NULL, NULL },
17324 8 { jwin_text_proc, 24, 106, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "2nd", NULL, NULL },
17325 8 { jwin_text_proc, 24, 152, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "3rd", NULL, NULL },
17326 8 { jwin_text_proc, 56, 60, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
17327 8 { jwin_text_proc, 56, 106, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
17328 8 { jwin_text_proc, 56, 152, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
17329 // 8
17330 8 { jwin_edit_proc, 86, 56, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17331 8 { d_ndroplist_proc, 56, 74, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17332 8 { jwin_edit_proc, 86, 102, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17333 8 { d_ndroplist_proc, 56, 120, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17334 8 { jwin_edit_proc, 86, 148, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17335 8 { d_ndroplist_proc, 56, 166, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17336 8 { jwin_text_proc, 24, 42, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Name:", NULL, NULL },
17337 8 { jwin_edit_proc, 56, 38, 137, 16, vc(12), vc(1), 0, 0, 31, 0, NULL, NULL, NULL },
17338 // 16
17339 8 { jwin_button_proc, 34, 188, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
17340 8 { jwin_button_proc, 114, 188, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
17341 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
17342 };
17343
17344 void EditInfoType(int32_t index)
17345 {
17346 char ps1[6],ps2[6],ps3[6];
17347 char infoname[32];
17348 char caption[40];
17349
17350 int32_t str1, str2, str3;
17351
17352 sprintf(caption,"Info Data %d",index);
17353 editinfo_dlg[0].dp = caption;
17354 editinfo_dlg[0].dp2 = get_zc_font(font_lfont);
17355
17356 sprintf(ps1,"%d",QMisc.info[index].price[0]);
17357 sprintf(ps2,"%d",QMisc.info[index].price[1]);
17358 sprintf(ps3,"%d",QMisc.info[index].price[2]);
17359 snprintf(infoname,32,"%s",QMisc.info[index].name);
17360 editinfo_dlg[8].dp = ps1;
17361 editinfo_dlg[10].dp = ps2;
17362 editinfo_dlg[12].dp = ps3;
17363 editinfo_dlg[15].dp = infoname;
17364 str1 = QMisc.info[index].str[0];
17365 str2 = QMisc.info[index].str[1];
17366 str3 = QMisc.info[index].str[2];
17367 editinfo_dlg[9].d1 = MsgStrings[str1].listpos;
17368 editinfo_dlg[11].d1 = MsgStrings[str2].listpos;
17369 editinfo_dlg[13].d1 = MsgStrings[str3].listpos;
17370 ListData msgs_list(msgslist2, &a4fonts[font_lfont_l]);
17371 editinfo_dlg[9].dp =
17372 editinfo_dlg[11].dp =
17373 editinfo_dlg[13].dp = (void *) &msgs_list;
17374
17375 large_dialog(editinfo_dlg);
17376
17377 int32_t ret = do_zqdialog(editinfo_dlg,-1);
17378
17379 if(ret==16)
17380 {
17381 saved=false;
17382 QMisc.info[index].price[0] = vbound(atoi(ps1), 0, 65535);
17383 QMisc.info[index].price[1] = vbound(atoi(ps2), 0, 65535);
17384 QMisc.info[index].price[2] = vbound(atoi(ps3), 0, 65535);
17385 snprintf(QMisc.info[index].name,32,"%s",infoname);
17386 str1 = editinfo_dlg[9].d1;
17387 str2 = editinfo_dlg[11].d1;
17388 str3 = editinfo_dlg[13].d1;
17389 QMisc.info[index].str[0] = msg_at_pos(str1);
17390 QMisc.info[index].str[1] = msg_at_pos(str2);
17391 QMisc.info[index].str[2] = msg_at_pos(str3);
17392
17393 //move 0s to the end
17394 word swaptmp;
17395
17396 if(QMisc.info[index].str[0] == 0)
17397 {
17398 //possibly permute the infos
17399 if(QMisc.info[index].str[1] != 0)
17400 {
17401 //swap
17402 swaptmp = QMisc.info[index].str[0];
17403 QMisc.info[index].str[0] = QMisc.info[index].str[1];
17404 QMisc.info[index].str[1] = swaptmp;
17405 swaptmp = QMisc.info[index].price[0];
17406 QMisc.info[index].price[0] = QMisc.info[index].price[1];
17407 QMisc.info[index].price[1] = swaptmp;
17408 }
17409 else if(QMisc.info[index].str[2] != 0)
17410 {
17411 //move info 0 to 1, 1 to 2, and 2 to 0
17412 swaptmp = QMisc.info[index].str[0];
17413 QMisc.info[index].str[0] = QMisc.info[index].str[2];
17414 QMisc.info[index].str[2] = QMisc.info[index].str[1];
17415 QMisc.info[index].str[1] = swaptmp;
17416 swaptmp = QMisc.info[index].price[0];
17417 QMisc.info[index].price[0] = QMisc.info[index].price[2];
17418 QMisc.info[index].price[2] = QMisc.info[index].price[1];
17419 QMisc.info[index].price[1] = swaptmp;
17420 }
17421 }
17422
17423 if(QMisc.info[index].str[1] == 0 && QMisc.info[index].str[2] != 0)
17424 //swap
17425 {
17426 swaptmp = QMisc.info[index].str[1];
17427 QMisc.info[index].str[1] = QMisc.info[index].str[2];
17428 QMisc.info[index].str[2] = swaptmp;
17429 swaptmp = QMisc.info[index].price[1];
17430 QMisc.info[index].price[1] = QMisc.info[index].price[2];
17431 QMisc.info[index].price[2] = swaptmp;
17432 }
17433 }
17434 }
17435
17436 int32_t onInfoTypes()
17437 {
17438 info_list_size = 256;
17439
17440 int32_t index = select_data("Info Types",0,infolist,"Edit","Done",get_zc_font(font_lfont));
17441
17442 while(index!=-1)
17443 {
17444 EditInfoType(index);
17445
17446 index = select_data("Info Types",index,infolist,"Edit","Done",get_zc_font(font_lfont));
17447 }
17448
17449 return D_O_K;
17450 }
17451
17452
17453
17454 //This dialogie is self-contained, and does not use dialogue control numbers in a separate array to generate its fields.
17455 static DIALOG editshop_dlg[] =
17456 {
17457 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
17458 8 { jwin_win_proc, 0, 10, 221, 204, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
17459 8 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
17460 8 { jwin_text_proc, 24, 60, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "1st", NULL, NULL },
17461 8 { jwin_text_proc, 24, 106, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "2nd", NULL, NULL },
17462 8 { jwin_text_proc, 24, 152, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "3rd", NULL, NULL },
17463 8 { jwin_text_proc, 56, 60, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
17464 8 { jwin_text_proc, 56, 106, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
17465 8 { jwin_text_proc, 56, 152, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
17466 // 8
17467 8 { jwin_edit_proc, 86, 56, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17468 8 { d_nidroplist_proc, 56, 74, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17469 8 { jwin_edit_proc, 86, 102, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17470 8 { d_nidroplist_proc, 56, 120, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17471 8 { jwin_edit_proc, 86, 148, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17472 8 { d_nidroplist_proc, 56, 166, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17473 8 { jwin_text_proc, 24, 42, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Name:", NULL, NULL },
17474 8 { jwin_edit_proc, 56, 38, 137, 16, vc(12), vc(1), 0, 0, 31, 0, NULL, NULL, NULL },
17475
17476 // 16
17477 8 { jwin_button_proc, 40, 188, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
17478 8 { jwin_button_proc, 121, 188, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
17479 //18
17480 8 { jwin_text_proc, 130, 60, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Info:", NULL, NULL },
17481 8 { jwin_text_proc, 130, 106, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Info:", NULL, NULL },
17482 8 { jwin_text_proc, 130, 152, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Info:", NULL, NULL },
17483 // 21
17484 8 { jwin_edit_proc, 155, 56, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17485 8 { jwin_edit_proc, 155, 102, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17486 8 { jwin_edit_proc, 155, 148, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17487
17488 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
17489 };
17490
17491 void EditShopType(int32_t index)
17492 {
17493
17494 build_bii_list(true);
17495 char ps1[6],ps2[6],ps3[6];
17496 char info1[6],info2[6],info3[6];
17497 char shopname[32];
17498 char caption[40];
17499
17500 sprintf(caption,"Shop Data %d",index);
17501 editshop_dlg[0].dp = caption;
17502 editshop_dlg[0].dp2=get_zc_font(font_lfont);
17503
17504 sprintf(ps1,"%d",QMisc.shop[index].price[0]);
17505 sprintf(ps2,"%d",QMisc.shop[index].price[1]);
17506 sprintf(ps3,"%d",QMisc.shop[index].price[2]);
17507
17508 sprintf(info1,"%d",QMisc.shop[index].str[0]);
17509 sprintf(info2,"%d",QMisc.shop[index].str[1]);
17510 sprintf(info3,"%d",QMisc.shop[index].str[2]);
17511
17512 sprintf(shopname,"%s",QMisc.shop[index].name);
17513 editshop_dlg[8].dp = ps1;
17514 editshop_dlg[10].dp = ps2;
17515 editshop_dlg[12].dp = ps3;
17516 editshop_dlg[15].dp = shopname;
17517
17518 editshop_dlg[21].dp = info1;
17519 editshop_dlg[22].dp = info2;
17520 editshop_dlg[23].dp = info3;
17521
17522 ListData item_list(itemlist_num, &a4fonts[font_lfont_l]);
17523
17524 editshop_dlg[9].dp = (void *) &item_list;
17525 editshop_dlg[11].dp = (void *) &item_list;
17526 editshop_dlg[13].dp = (void *) &item_list;
17527
17528 for(int32_t i=0; i<3; ++i)
17529 {
17530 if(QMisc.shop[index].hasitem[i])
17531 {
17532 for(int32_t j=0; j<bii_cnt; j++)
17533 {
17534 if(bii[j].i == QMisc.shop[index].item[i])
17535 {
17536 editshop_dlg[9+(i<<1)].d1 = j;
17537 }
17538 }
17539 }
17540 else
17541 {
17542 editshop_dlg[9+(i<<1)].d1 = -2;
17543 }
17544 }
17545
17546 large_dialog(editshop_dlg);
17547
17548 int32_t ret = do_zqdialog(editshop_dlg,-1);
17549
17550 if(ret==16)
17551 {
17552 saved=false;
17553 QMisc.shop[index].price[0] = vbound(atoi(ps1), 0, 65535);
17554 QMisc.shop[index].price[1] = vbound(atoi(ps2), 0, 65535);
17555 QMisc.shop[index].price[2] = vbound(atoi(ps3), 0, 65535);
17556
17557 QMisc.shop[index].str[0] = vbound(atoi(info1), 0, 65535);
17558 QMisc.shop[index].str[1] = vbound(atoi(info2), 0, 65535);
17559 QMisc.shop[index].str[2] = vbound(atoi(info3), 0, 65535);
17560
17561 snprintf(QMisc.shop[index].name, 32, "%s",shopname);
17562
17563 for(int32_t i=0; i<3; ++i)
17564 {
17565 if(bii[editshop_dlg[9+(i<<1)].d1].i == -2)
17566 {
17567 QMisc.shop[index].hasitem[i] = 0;
17568 QMisc.shop[index].item[i] = 0;
17569 QMisc.shop[index].price[i] = 0;
17570 }
17571 else
17572 {
17573 QMisc.shop[index].hasitem[i] = 1;
17574 QMisc.shop[index].item[i] = bii[editshop_dlg[9+(i<<1)].d1].i;
17575 }
17576 }
17577
17578 //filter all the 0 items to the end (yeah, bubble sort; sue me)
17579 word swaptmp;
17580
17581 for(int32_t j=0; j<3-1; j++)
17582 {
17583 for(int32_t k=0; k<2-j; k++)
17584 {
17585 if(QMisc.shop[index].hasitem[k]==0)
17586 {
17587 swaptmp = QMisc.shop[index].item[k];
17588 QMisc.shop[index].item[k] = QMisc.shop[index].item[k+1];
17589 QMisc.shop[index].item[k+1] = swaptmp;
17590 swaptmp = QMisc.shop[index].price[k];
17591 QMisc.shop[index].price[k] = QMisc.shop[index].price[k+1];
17592 QMisc.shop[index].price[k+1] = swaptmp;
17593 swaptmp = QMisc.shop[index].hasitem[k];
17594 QMisc.shop[index].hasitem[k] = QMisc.shop[index].item[k+1];
17595 QMisc.shop[index].hasitem[k+1] = swaptmp;
17596 }
17597 }
17598 }
17599 }
17600 }
17601
17602 int32_t onShopTypes()
17603 {
17604 shop_list_size = 256;
17605
17606 int32_t index = select_data("Shop Types",0,shoplist,"Edit","Done",get_zc_font(font_lfont));
17607
17608 while(index!=-1)
17609 {
17610 EditShopType(index);
17611 index = select_data("Shop Types",index,shoplist,"Edit","Done",get_zc_font(font_lfont));
17612 }
17613
17614 return D_O_K;
17615 }
17616
17617 void call_bottle_dlg(int32_t index);
17618 int32_t onBottleTypes()
17619 {
17620 bottle_list_size = 64;
17621 int32_t index = 0;
17622
17623 while(index > -1)
17624 {
17625 index = select_data("Bottle Types", index, bottlelist, "Edit", "Done", get_zc_font(font_lfont));
17626 if(index > -1)
17627 call_bottle_dlg(index);
17628 }
17629
17630 return D_O_K;
17631 }
17632
17633 void call_bottleshop_dlg(int32_t index);
17634 int32_t onBottleShopTypes()
17635 {
17636 bottleshop_list_size = 256;
17637 int32_t index = 0;
17638
17639 while(index > -1)
17640 {
17641 index = select_data("Bottle Shop Types", index, bottleshoplist, "Edit", "Done", get_zc_font(font_lfont));
17642 if(index > -1)
17643 call_bottleshop_dlg(index);
17644 }
17645
17646 return D_O_K;
17647 }
17648
17649
17650 static char item_drop_set_str_buf[70];
17651 int32_t item_drop_set_list_size=MAXITEMDROPSETS;
17652
17653 const char *itemdropsetlist(int32_t index, int32_t *list_size)
17654 {
17655 if(index>=0)
17656 {
17657 bound(index,0,item_drop_set_list_size-1);
17658 sprintf(item_drop_set_str_buf,"%3d: %s",index,item_drop_sets[index].name);
17659 return item_drop_set_str_buf;
17660 }
17661
17662 *list_size=item_drop_set_list_size;
17663 return NULL;
17664 }
17665
17666 int32_t d_itemdropedit_proc(int32_t msg,DIALOG *d,int32_t c);
17667
17668 static int32_t edititemdropset_1_list[] =
17669 {
17670 // dialog control number
17671 10, 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,24,25,26,27,28, -1
17672 };
17673
17674 static int32_t edititemdropset_2_list[] =
17675 {
17676 // dialog control number
17677 12, 13, 29, 30, 31, 32, 33,34,35,36,37,38,39,40,41,42,43, -1
17678 };
17679
17680 static TABPANEL edititemdropset_tabs[] =
17681 {
17682 // (text)
17683 { (char *)" Page 1 ", D_SELECTED, edititemdropset_1_list, 0, NULL },
17684 { (char *)" Page 2 ", 0, edititemdropset_2_list, 0, NULL },
17685 { NULL, 0, NULL, 0, NULL }
17686 };
17687
17688 static DIALOG edititemdropset_dlg[] =
17689 {
17690 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
17691 8 { jwin_win_proc, 0, 0, 320, 240, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
17692 8 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
17693
17694 // 2
17695 8 { jwin_button_proc, 89, 213, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
17696 8 { jwin_button_proc, 169, 213, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
17697
17698 // 4
17699 8 { jwin_text_proc, 9, 29, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Name:", NULL, NULL },
17700 8 { jwin_edit_proc, 39, 25, 275, 16, vc(12), vc(1), 0, 0, 32, 0, NULL, NULL, NULL },
17701 8 { jwin_text_proc, 9, 47, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Nothing Chance:", NULL, NULL },
17702 8 { d_itemdropedit_proc, 84, 43, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17703
17704 8 { jwin_tab_proc, 4, 65, 312, 143, vc(0), vc(15), 0, 0, 0, 0, (void *) edititemdropset_tabs, NULL, (void *)edititemdropset_dlg },
17705 8 { jwin_text_proc, 114, 43+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
17706 // 10
17707 8 { jwin_text_proc, 10, 87, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Chance:", NULL, NULL },
17708 8 { jwin_text_proc, 56, 87, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Item:", NULL, NULL },
17709 8 { jwin_text_proc, 10, 87, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Chance:", NULL, NULL },
17710 8 { jwin_text_proc, 56, 87, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Item:", NULL, NULL },
17711
17712 // 14
17713 8 { d_itemdropedit_proc, 9, 96, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17714 8 { d_idroplist_proc, 55, 96, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17715 8 { jwin_text_proc, 37, 96+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
17716 8 { d_itemdropedit_proc, 9, 118, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17717 8 { d_idroplist_proc, 55, 118, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17718 8 { jwin_text_proc, 37, 118+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
17719 8 { d_itemdropedit_proc, 9, 140, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17720 8 { d_idroplist_proc, 55, 140, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17721 8 { jwin_text_proc, 37, 140+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
17722 8 { d_itemdropedit_proc, 9, 162, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17723 8 { d_idroplist_proc, 55, 162, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17724 8 { jwin_text_proc, 37, 162+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
17725 8 { d_itemdropedit_proc, 9, 184, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17726 8 { d_idroplist_proc, 55, 184, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17727 8 { jwin_text_proc, 37, 184+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
17728 // 29
17729 8 { d_itemdropedit_proc, 9, 96, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17730 8 { d_idroplist_proc, 55, 96, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17731 8 { jwin_text_proc, 37, 96+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
17732 8 { d_itemdropedit_proc, 9, 118, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17733 8 { d_idroplist_proc, 55, 118, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17734 8 { jwin_text_proc, 37, 118+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
17735 8 { d_itemdropedit_proc, 9, 140, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17736 8 { d_idroplist_proc, 55, 140, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17737 8 { jwin_text_proc, 37, 140+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
17738 8 { d_itemdropedit_proc, 9, 162, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17739 8 { d_idroplist_proc, 55, 162, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17740 8 { jwin_text_proc, 37, 162+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
17741 8 { d_itemdropedit_proc, 9, 184, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17742 8 { d_idroplist_proc, 55, 184, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17743 8 { jwin_text_proc, 39, 184+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
17744 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
17745 };
17746
17747 int32_t d_itemdropedit_proc(int32_t msg,DIALOG *d,int32_t c)
17748 {
17749 int32_t ret = jwin_edit_proc(msg,d,c);
17750
17751 if(msg==MSG_DRAW)
17752 {
17753 int32_t t = atoi((char*)edititemdropset_dlg[7].dp);
17754
17755 for(int32_t i=0; i<10; ++i)
17756 {
17757 t += atoi((char*)edititemdropset_dlg[14+(i*3)].dp);
17758 }
17759
17760 {
17761 int32_t t2 = (int32_t)(100*atoi((char*)edititemdropset_dlg[7].dp) / zc_max(t,1));
17762 sprintf((char*)edititemdropset_dlg[9].dp,"%d%%%s",t2, t2 <= 11 ? " ":"");
17763 object_message(&edititemdropset_dlg[9],MSG_DRAW,c);
17764 }
17765
17766 for(int32_t i=0; i<10; ++i)
17767 {
17768 int32_t t2 = (int32_t)(100*atoi((char*)edititemdropset_dlg[14+(i*3)].dp) / zc_max(t,1));
17769 sprintf((char*)edititemdropset_dlg[16+(i*3)].dp,"%d%%%s",t2, t2 <= 11 ? " ":"");
17770 object_message(&edititemdropset_dlg[16+(i*3)],MSG_DRAW,c);
17771 }
17772
17773 }
17774
17775 return ret;
17776 }
17777
17778 void EditItemDropSet(int32_t index)
17779 {
17780 build_bii_list(true);
17781 char chance[11][10];
17782 char itemdropsetname[64];
17783 char caption[40];
17784 char percent_str[11][5];
17785
17786 sprintf(caption,"Item Drop Set Data %d",index);
17787 edititemdropset_dlg[0].dp = caption;
17788 edititemdropset_dlg[0].dp2=get_zc_font(font_lfont);
17789
17790 sprintf(itemdropsetname,"%s",item_drop_sets[index].name);
17791 edititemdropset_dlg[5].dp = itemdropsetname;
17792
17793 sprintf(chance[0],"%d",item_drop_sets[index].chance[0]);
17794 edititemdropset_dlg[7].dp = chance[0];
17795
17796 ListData item_list(itemlist_num, &a4fonts[font_lfont_l]);
17797 sprintf(percent_str[0]," ");
17798 edititemdropset_dlg[9].dp = percent_str[0];
17799
17800 for(int32_t i=0; i<10; ++i)
17801 {
17802 sprintf(chance[i+1],"%d",item_drop_sets[index].chance[i+1]);
17803 edititemdropset_dlg[14+(i*3)].dp = chance[i+1];
17804 edititemdropset_dlg[15+(i*3)].dp = (void *) &item_list;
17805 sprintf(percent_str[i+1]," ");
17806 edititemdropset_dlg[16+(i*3)].dp = percent_str[i+1];
17807
17808 if(item_drop_sets[index].chance[i+1]==0)
17809 {
17810 edititemdropset_dlg[15+(i*3)].d1 = -2;
17811 }
17812 else
17813 {
17814 for(int32_t j=0; j<bii_cnt; j++)
17815 {
17816 if(bii[j].i == item_drop_sets[index].item[i])
17817 {
17818 edititemdropset_dlg[15+(i*3)].d1 = j;
17819 }
17820 }
17821 }
17822 }
17823
17824 large_dialog(edititemdropset_dlg);
17825
17826 int32_t ret = do_zqdialog(edititemdropset_dlg,-1);
17827
17828 if(ret==2)
17829 {
17830 saved=false;
17831
17832 sprintf(item_drop_sets[index].name,"%s",itemdropsetname);
17833
17834 item_drop_sets[index].chance[0]=atoi(chance[0]);
17835
17836 for(int32_t i=0; i<10; ++i)
17837 {
17838 item_drop_sets[index].chance[i+1]=atoi(chance[i+1]);
17839
17840 if(bii[edititemdropset_dlg[15+(i*3)].d1].i == -2)
17841 {
17842 item_drop_sets[index].chance[i+1]=0;
17843 }
17844 else
17845 {
17846 item_drop_sets[index].item[i] = bii[edititemdropset_dlg[15+(i*3)].d1].i;
17847 }
17848
17849 if(item_drop_sets[index].chance[i+1]==0)
17850 {
17851 item_drop_sets[index].item[i] = 0;
17852 }
17853 }
17854 }
17855 }
17856
17857 5 int32_t count_item_drop_sets()
17858 {
17859 5 int32_t count=0;
17860 5 bool found=false;
17861
17862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1219 times.
1219 for(count=255; (count>0); --count)
17863 {
17864
2/2
✓ Branch 0 taken 1214 times.
✓ Branch 1 taken 13360 times.
14574 for(int32_t i=0; (i<11); ++i)
17865 {
17866
2/2
✓ Branch 0 taken 13355 times.
✓ Branch 1 taken 5 times.
13360 if(item_drop_sets[count].chance[i]!=0)
17867 {
17868 5 found=true;
17869 5 break;
17870 }
17871 13355 }
17872
17873
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1214 times.
1219 if(found)
17874 {
17875 5 break;
17876 }
17877 1214 }
17878
17879 5 return count+1;
17880 }
17881
17882 int32_t onItemDropSets()
17883 {
17884 item_drop_set_list_size = MAXITEMDROPSETS;
17885
17886 int32_t index = select_data("Item Drop Sets",0,itemdropsetlist,"Edit","Done",get_zc_font(font_lfont));
17887
17888 while(index!=-1)
17889 {
17890 EditItemDropSet(index);
17891 index = select_data("Item Drop Sets",index,itemdropsetlist,"Edit","Done",get_zc_font(font_lfont));
17892 }
17893
17894 return D_O_K;
17895 }
17896
17897 /********************************/
17898 /********* onWarpRings **********/
17899 /********************************/
17900
17901 int32_t curr_ring = 0;
17902
17903 void EditWarpRingScr(int32_t ring,int32_t index)
17904 {
17905 char caption[40],buf[10];
17906 restore_mouse();
17907
17908 sprintf(caption,"Ring %d Warp %d",ring,index+1);
17909 warpring_warp_dlg[0].dp = (void *)caption;
17910 warpring_warp_dlg[0].dp2=get_zc_font(font_lfont);
17911
17912 sprintf(buf,"%02X",QMisc.warp[ring].scr[index]);
17913 warpring_warp_dlg[3].d1 = QMisc.warp[ring].dmap[index];
17914 warpring_warp_dlg[4].dp = buf;
17915 warpring_warp_dlg[8].dp = buf;
17916 warpring_warp_dlg[8].dp3 = &warpring_warp_dlg[3].d1;
17917
17918 vector<DIALOG*> dlgs;
17919 dlgs.push_back(&warpring_warp_dlg[3]);
17920 dlgs.push_back(&warpring_warp_dlg[4]);
17921 warpring_warp_dlg[8].dp2 = &dlgs;
17922
17923 dmap_list_size=MAXDMAPS;
17924 dmap_list_zero=true;
17925
17926 large_dialog(warpring_warp_dlg);
17927
17928 int32_t ret=do_zqdialog(warpring_warp_dlg,-1);
17929
17930 if(ret==5 || ret==6)
17931 {
17932 saved=false;
17933 QMisc.warp[ring].dmap[index] = warpring_warp_dlg[3].d1;
17934 QMisc.warp[ring].scr[index] = zc_xtoi(buf);
17935 }
17936
17937 if(ret==6)
17938 {
17939 Map.dowarp2(ring,index);
17940 refresh(rALL);
17941 }
17942 }
17943
17944 int32_t d_warplist_proc(int32_t msg,DIALOG *d,int32_t c)
17945 {
17946 if(msg==MSG_DRAW)
17947 {
17948 int32_t *xy = (int32_t*)(d->dp3);
17949 int32_t ring = curr_ring;
17950 int32_t dmap = QMisc.warp[ring].dmap[d->d1];
17951 float temp_scale = 1.5;
17952
17953 drawdmap(dmap);
17954
17955 if(xy[0]||xy[1])
17956 {
17957 int32_t x = d->x+int32_t((xy[0]-2)*temp_scale);
17958 int32_t y = d->y+int32_t((xy[1]-2)*temp_scale);
17959 int32_t w = 84;
17960 int32_t h = 52;
17961 jwin_draw_frame(screen,x,y,w,h,FR_DEEP);
17962 drawdmap_screen(x+2,y+2,w-4,h-4,dmap);
17963 }
17964
17965 if(xy[2]||xy[3])
17966 {
17967 textprintf_ex(screen,font,d->x+int32_t(xy[2]*temp_scale),d->y+int32_t(xy[3]*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Map: %d ",DMaps[dmap].map+1);
17968 }
17969
17970 if(xy[4]||xy[5])
17971 {
17972 textprintf_ex(screen,font,d->x+int32_t(xy[4]*temp_scale),d->y+int32_t(xy[5]*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Level:%2d ",DMaps[dmap].level);
17973 }
17974
17975 if(xy[6]||xy[7])
17976 {
17977 textprintf_ex(screen,font,d->x+int32_t(xy[6]*temp_scale),d->y+int32_t(xy[7]*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Scr: 0x%02X ",QMisc.warp[ring].scr[d->d1]);
17978 }
17979 }
17980
17981 return jwin_list_proc(msg,d,c);
17982 }
17983
17984 int32_t d_wclist_proc(int32_t msg,DIALOG *d,int32_t c)
17985 {
17986 int32_t d1 = d->d1;
17987 int32_t ret = jwin_droplist_proc(msg,d,c);
17988 QMisc.warp[curr_ring].size=d->d1+3;
17989
17990 if(d->d1 != d1)
17991 return D_CLOSE;
17992
17993 return ret;
17994 }
17995
17996 const char *wclist(int32_t index, int32_t *list_size)
17997 {
17998 static char buf[2];
17999
18000 if(index>=0)
18001 {
18002 if(index>6)
18003 index=6;
18004
18005 sprintf(buf,"%d",index+3);
18006 return buf;
18007 }
18008
18009 *list_size=7;
18010 return NULL;
18011 }
18012
18013 //int32_t warpringdmapxy[8] = {160,116,160,90,160,102,160,154};
18014 int32_t warpringdmapxy[8] = {80,26,80,0,80,12,80,78};
18015
18016 8 static ListData number_list(numberlist, &font);
18017 8 static ListData wc_list(wclist, &font);
18018
18019 static DIALOG warpring_dlg[] =
18020 {
18021 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
18022 8 { jwin_win_proc, 0, 0, 193, 166, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
18023 8 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
18024 8 { jwin_text_proc, 16, 33, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Count:", NULL, NULL },
18025 8 { d_wclist_proc, 72, 29, 48, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 1, 0, (void *) &wc_list, NULL, NULL },
18026 // 4
18027 8 { d_warplist_proc, 16, 50, 65, 71, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &number_list, NULL, warpringdmapxy },
18028 8 { jwin_button_proc, 26, 140, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Edit", NULL, NULL },
18029 8 { jwin_button_proc, 106, 140, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Done", NULL, NULL },
18030 8 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
18031 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
18032 };
18033
18034 int32_t select_warp()
18035 {
18036 QMisc.warp[curr_ring].size = vbound(QMisc.warp[curr_ring].size,3,9);
18037 number_list_zero = false;
18038
18039 int32_t ret=4;
18040
18041 large_dialog(warpring_dlg);
18042
18043 do
18044 {
18045 number_list_size = QMisc.warp[curr_ring].size;
18046 warpring_dlg[3].d1 = QMisc.warp[curr_ring].size-3;
18047 ret = do_zqdialog(warpring_dlg,ret);
18048 }
18049 while(ret==3);
18050
18051 if(ret==6 || ret==0)
18052 {
18053 return -1;
18054 }
18055
18056 return warpring_dlg[4].d1;
18057 }
18058
18059 void EditWarpRing(int32_t ring)
18060 {
18061 char buf[40];
18062 sprintf(buf,"Ring %d Warps",ring);
18063 warpring_dlg[0].dp = buf;
18064 warpring_dlg[0].dp2 = get_zc_font(font_lfont);
18065 curr_ring = ring;
18066
18067 int32_t index = select_warp();
18068
18069 while(index!=-1)
18070 {
18071 EditWarpRingScr(ring,index);
18072 index = select_warp();
18073 }
18074 }
18075
18076 int32_t onWarpRings()
18077 {
18078 number_list_size = 9;
18079 number_list_zero = true;
18080
18081 int32_t index = select_data("Warp Rings",0,numberlist,"Edit","Done",get_zc_font(font_lfont));
18082
18083 while(index!=-1)
18084 {
18085 EditWarpRing(index);
18086 number_list_size = 9;
18087 number_list_zero = true;
18088 index = select_data("Warp Rings",index,numberlist,"Edit","Done",get_zc_font(font_lfont));
18089 }
18090
18091 return D_O_K;
18092 }
18093
18094 /********************************/
18095 /********** onEnemies ***********/
18096 /********************************/
18097
18098
18099 const char *pattern_list(int32_t index, int32_t *list_size)
18100 {
18101
18102 if(index<0)
18103 {
18104 *list_size = MAXPATTERNS;
18105 return NULL;
18106 }
18107
18108 return pattern_string[index];
18109 }
18110
18111 8 static ListData pattern_dlg_list(pattern_list, &font);
18112
18113 static DIALOG pattern_dlg[] =
18114 {
18115 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
18116 8 { jwin_win_proc, 72, 56, 176+1, 164+1, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Enemy Pattern", NULL, NULL },
18117 8 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
18118 8 { jwin_list_proc, 80, 124, 160+1, 58, jwin_pal[jcTEXTFG],jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &pattern_dlg_list, NULL, NULL },
18119 // 3
18120 8 { jwin_button_proc, 90, 190, 61, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
18121 8 { jwin_button_proc, 170, 190, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
18122 8 { jwin_text_proc, 90, 78, 61, 10, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Classic: pseudorandom locations near", NULL, NULL },
18123 8 { jwin_text_proc, 90, 88, 61, 10, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "the middle of the screen.", NULL, NULL },
18124 8 { jwin_text_proc, 90, 102, 61, 10, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Random: any available location", NULL, NULL },
18125 8 { jwin_text_proc, 90, 112, 61, 10, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "at a sufficient distance from the Player.", NULL, NULL },
18126 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
18127 };
18128
18129 int32_t onPattern()
18130 {
18131 byte p=Map.CurrScr()->pattern;
18132 pattern_dlg[0].dp2 = get_zc_font(font_lfont);
18133 pattern_dlg[2].d1 = p;
18134
18135 large_dialog(pattern_dlg);
18136
18137 if(do_zqdialog(pattern_dlg,2) < 4)
18138 {
18139 saved=false;
18140 Map.CurrScr()->pattern = pattern_dlg[2].d1;
18141 }
18142
18143 refresh(rMENU);
18144 return D_O_K;
18145 }
18146
18147 int32_t onEnemyFlags()
18148 {
18149 call_screendata_dialog(3);
18150 return D_O_K;
18151 }
18152
18153 const char *enemy_viewer(int32_t index, int32_t *list_size)
18154 {
18155 if(index<0)
18156 {
18157 *list_size=10;
18158
18159 return NULL;
18160 }
18161
18162 int32_t guy=Map.CurrScr()->enemy[index];
18163
18164 if (guy == 0) return "(None)";
18165 return guy>=eSTART ? guy_string[guy] : (char *) "(Guy - Do Not Use!)";
18166 }
18167
18168 enemy_struct bie[eMAXGUYS];
18169 enemy_struct ce[100];
18170 int32_t enemy_type=0,bie_cnt=-1,ce_cnt;
18171
18172 enemy_struct big[zqMAXGUYS];
18173 enemy_struct cg[100];
18174 int32_t guy_type=0,big_cnt=-1,cg_cnt;
18175
18176 //Uses old_max_guys[] in zq_misc.cpp to define what are visible if bool hide is set true. -Z
18177 void build_bie_list(bool hide)
18178 {
18179 bie[0].s = (char *)"(None)";
18180 bie[0].i = 0;
18181 bie_cnt=1;
18182
18183 for(int32_t i=1; i<eMAXGUYS; i++)
18184 {
18185 if (i < eSTART) continue; // ignore guys - enemies only!
18186
18187 if(i >= OLDMAXGUYS || old_guy_string[i][strlen(old_guy_string[i])-1]!=' ' || !hide)
18188 {
18189 bie[bie_cnt].s = (char *)guy_string[i];
18190 bie[bie_cnt].i = i;
18191 ++bie_cnt;
18192 }
18193 }
18194
18195 for(int32_t i=1; i<bie_cnt-1; i++) //Start at 1 so '(None)' isn't alphabetized!
18196 {
18197 for(int32_t j=i+1; j<bie_cnt; j++)
18198 {
18199 if(strcmp(bie[i].s,bie[j].s)>0)
18200 {
18201 zc_swap(bie[i],bie[j]);
18202 }
18203 }
18204 }
18205 }
18206
18207 void build_big_list(bool hide)
18208 {
18209 //big[0].s = (char *)"(None)";
18210 //big[0].i = 0;
18211 //big_cnt=1;
18212 big_cnt=0;
18213 for(int32_t i=0; i<gDUMMY1; i++)
18214 {
18215 if(moduledata.guy_type_names[i][0]!=' ' || !hide)
18216 {
18217 big[big_cnt].s = (char *)moduledata.guy_type_names[i];
18218 big[big_cnt].i = i;
18219 ++big_cnt;
18220 }
18221 }
18222
18223 for(int32_t i=1; i<big_cnt-1; i++) //start at 1, so that the none value is not alphabetized.
18224 {
18225 for(int32_t j=i+1; j<big_cnt; j++)
18226 {
18227 if(strcmp(big[i].s,big[j].s)>0)
18228 {
18229 zc_swap(big[i],big[j]);
18230 }
18231 }
18232 }
18233 }
18234
18235 const char *enemylist(int32_t index, int32_t *list_size)
18236 {
18237 if(index<0)
18238 {
18239 *list_size = enemy_type ? ce_cnt : bie_cnt;
18240 return NULL;
18241 }
18242
18243 return enemy_type ? ce[index].s : bie[index].s;
18244 }
18245
18246 const char *guylist(int32_t index, int32_t *list_size)
18247 {
18248 if(index<0)
18249 {
18250 *list_size = guy_type ? cg_cnt : big_cnt;
18251 return NULL;
18252 }
18253
18254 return guy_type ? cg[index].s : big[index].s;
18255 }
18256
18257 void elist_rclick_func(int32_t index, int32_t x, int32_t y);
18258 void paste_enemy(int32_t index = -1);
18259 void copy_enemy(int32_t index = -1);
18260 void save_enemy(int32_t index = -1);
18261 void load_enemy(int32_t index = -1);
18262 DIALOG elist_dlg[] =
18263 {
18264 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
18265 8 { jwin_win_proc, 50, 40, 288, 175, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
18266 8 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
18267 8 { d_enelist_proc, 62, 68, 188, 98, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, NULL, NULL, NULL },
18268 8 { jwin_button_proc, 90, 160+20, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Edit", NULL, NULL },
18269 8 { jwin_button_proc, 170, 160+20, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Done", NULL, NULL },
18270 8 { jwin_button_proc, 220, 160+20, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Edit", NULL, NULL },
18271 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
18272 };
18273
18274 static DIALOG glist_dlg[] =
18275 {
18276 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
18277 8 { jwin_win_proc, 50, 40, 220, 145, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
18278 8 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
18279 8 { jwin_abclist_proc, 62, 68, 196, 88, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, NULL, NULL, NULL },
18280 8 { jwin_button_proc, 70, 160, 51, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
18281 8 { jwin_button_proc, 190, 160, 51, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
18282 8 { jwin_button_proc, 130, 160, 51, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Help", NULL, NULL },
18283 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
18284 };
18285
18286 int32_t efrontfacingtile(int32_t id)
18287 {
18288 int32_t anim = get_qr(qr_NEWENEMYTILES)?guysbuf[id].e_anim:guysbuf[id].anim;
18289 int32_t usetile = 0;
18290
18291 switch(anim)
18292 {
18293
18294 case aNONE: break;
18295 case aAQUA:
18296 if(!(get_qr(qr_NEWENEMYTILES) && guysbuf[id].misc1))
18297 break;
18298
18299 case aWALLM:
18300 case aGHOMA:
18301 usetile=1;
18302 break;
18303
18304 //Fallthrough
18305 case a2FRM4DIR:
18306 case aWALK:
18307 usetile=2;
18308 break;
18309
18310 case aLEV:
18311 case a3FRM4DIR:
18312 usetile=3;
18313 break;
18314
18315 case aLANM:
18316 usetile = !(get_qr(qr_NEWENEMYTILES))?0:4;
18317 break;
18318
18319 case aNEWDONGO:
18320 case a4FRM8EYE:
18321 case aNEWWIZZ:
18322 case aARMOS4:
18323 case aNEWTEK:
18324 case aNEWWALLM:
18325 case a4FRM4DIRF:
18326 case a4FRM4DIR:
18327 case a4FRM8DIRF:
18328 case a4FRMPOS8DIR:
18329 case a4FRMPOS8DIRF:
18330 case a4FRMPOS4DIR:
18331 case a4FRMPOS4DIRF:
18332 usetile=4;
18333 break;
18334
18335 case aDONGO:
18336 usetile=6;
18337 break;
18338
18339 case aDONGOBS:
18340 usetile=24;
18341 break;
18342
18343 case aNEWLEV:
18344 usetile=40;
18345 break;
18346
18347 case aNEWZORA:
18348 if(guysbuf[id].family==eeZORA)
18349 usetile=44;
18350
18351 break;
18352
18353 case aGLEEOK:
18354 if(!get_qr(qr_NEWENEMYTILES))
18355 usetile = (guysbuf[id].s_tile - guysbuf[id].tile)+1;
18356 else
18357 usetile = (guysbuf[id].misc8);
18358
18359 break;
18360 }
18361
18362 return zc_max(get_qr(qr_NEWENEMYTILES) ? -guysbuf[id].e_tile
18363 : -guysbuf[id].tile, usetile);
18364 }
18365
18366 8 static ListData enemy_dlg_list(enemy_viewer, &font);
18367
18368 int32_t enelist_proc(int32_t msg,DIALOG *d,int32_t c,bool use_abc_list)
18369 {
18370 FONT* oldfont = font;
18371 bool is_screen_select = d->dp == &enemy_dlg_list;
18372 int32_t ret;
18373
18374 if(!is_screen_select && msg == MSG_XCHAR)
18375 {
18376 if(key_shifts & KB_CTRL_FLAG) //CTRL overrides the lister search function
18377 {
18378 int32_t ret = D_USED_CHAR;
18379 switch(c>>8)
18380 {
18381 case KEY_V:
18382 paste_enemy();
18383 break;
18384 case KEY_C:
18385 copy_enemy();
18386 break;
18387 case KEY_S:
18388 save_enemy();
18389 break;
18390 case KEY_L:
18391 load_enemy();
18392 break;
18393 default: ret = 0;
18394 }
18395 if(ret) return ret;
18396 }
18397 }
18398
18399 if(use_abc_list)
18400 ret= jwin_abclist_proc(msg,d,c);
18401 else
18402 ret= jwin_list_proc(msg,d,c);
18403
18404 if(msg==MSG_DRAW||msg==MSG_CHAR)
18405 {
18406 int32_t id;
18407
18408 // Conveniently hacking the Select Enemy and Screen Enemy dialogs together -L
18409 if(d->dp == &enemy_dlg_list)
18410 {
18411 id = Map.CurrScr()->enemy[d->d1];
18412 }
18413 else
18414 {
18415 id = bie[d->d1].i;
18416 }
18417
18418 int32_t tile = get_qr(qr_NEWENEMYTILES) ? guysbuf[id].e_tile
18419 : guysbuf[id].tile;
18420 int32_t cset = guysbuf[id].cset;
18421 int32_t x = d->x + int32_t(195 * 1.5);
18422 int32_t y = d->y + 3;
18423 int32_t w = 36;
18424 int32_t h = 36;
18425
18426 BITMAP *buf = create_bitmap_ex(8,20,20);
18427 BITMAP *bigbmp = create_bitmap_ex(8,w,h);
18428
18429 if(buf && bigbmp)
18430 {
18431 clear_bitmap(buf);
18432
18433 if(tile)
18434 overtile16(buf, tile+efrontfacingtile(id),2,2,cset,0);
18435
18436 stretch_blit(buf, bigbmp, 2,2, 17, 17, 2, 2,w-2, h-2);
18437 destroy_bitmap(buf);
18438 jwin_draw_frame(bigbmp,0,0,w,h,FR_DEEP);
18439 blit(bigbmp,screen,0,0,x,y,w,h);
18440 destroy_bitmap(bigbmp);
18441 }
18442
18443 font = get_zc_font(font_lfont_l);
18444 int fh = text_height(font);
18445 rectfill(screen,x,y+40,x+64,y+40+(10*fh),jwin_pal[jcBOX]);
18446 textprintf_ex(screen,font,x,y+40+(0*fh),jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"#%d",id);
18447
18448 textprintf_ex(screen,font,x,y+40+(1*fh),jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Tile: %d",guysbuf[id].tile);
18449
18450 textprintf_ex(screen,font,x,y+40+(2*fh),jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"sTil: %d",guysbuf[id].s_tile);
18451 textprintf_ex(screen,font,x,y+40+(3*fh),jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"eTil: %d",guysbuf[id].e_tile);
18452
18453 textprintf_ex(screen,font,x,y+40+(4*fh),jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"HP: %d",guysbuf[id].hp);
18454 textprintf_ex(screen,font,x,y+40+(5*fh),jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Dmg: %d",guysbuf[id].dp);
18455
18456 textprintf_ex(screen,font,x,y+40+(6*fh),jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Fam: %d",guysbuf[id].family);
18457 textprintf_ex(screen,font,x,y+40+(7*fh),jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Drop: %d",guysbuf[id].item_set);
18458 textprintf_ex(screen,font,x,y+40+(8*fh),jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Script: %d",guysbuf[id].script);
18459 textprintf_ex(screen,font,x,y+40+(9*fh),jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"WScript: %d",guysbuf[id].weaponscript);
18460 }
18461 font = oldfont;
18462 return ret;
18463 }
18464
18465 int32_t select_enemy(const char *prompt,int32_t enemy,bool hide,bool is_editor,int32_t &exit_status)
18466 {
18467 //if(bie_cnt==-1)
18468 {
18469 build_bie_list(hide);
18470 }
18471 int32_t index=0;
18472
18473 for(int32_t j=0; j<bie_cnt; j++)
18474 {
18475 if(bie[j].i == enemy)
18476 {
18477 index=j;
18478 }
18479 }
18480
18481 elist_dlg[0].dp=(void *)prompt;
18482 elist_dlg[0].dp2=get_zc_font(font_lfont);
18483 elist_dlg[2].d1=index;
18484 ListData enemy_list(enemylist, &font);
18485 elist_dlg[2].dp=(void *) &enemy_list;
18486
18487 large_dialog(elist_dlg);
18488
18489 if(is_editor)
18490 {
18491 elist_dlg[2].dp3 = (void *)&elist_rclick_func;
18492 elist_dlg[2].flags|=(D_USER<<1);
18493 elist_dlg[3].dp = (void *)"Edit";
18494 elist_dlg[4].dp = (void *)"Done";
18495 elist_dlg[3].x = 285;
18496 elist_dlg[4].x = 405;
18497 elist_dlg[5].flags |= D_HIDDEN;
18498 }
18499 else
18500 {
18501 elist_dlg[2].dp3 = NULL;
18502 elist_dlg[2].flags&=~(D_USER<<1);
18503 elist_dlg[3].dp = (void *)"OK";
18504 elist_dlg[4].dp = (void *)"Cancel";
18505 elist_dlg[3].x = 240;
18506 elist_dlg[4].x = 350;
18507 elist_dlg[5].flags &= ~D_HIDDEN;
18508 }
18509
18510 exit_status=do_zqdialog(elist_dlg,2);
18511
18512 if(exit_status==0||exit_status==4)
18513 {
18514 return -1;
18515 }
18516
18517 index = elist_dlg[2].d1;
18518 return bie[index].i;
18519 }
18520
18521 uint8_t check[2] = { (uint8_t)'\x81',0 };
18522
18523 static DIALOG enemy_dlg[] =
18524 {
18525 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
18526 8 { jwin_win_proc, 0, 0, 256, 190+10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Enemies", NULL, NULL },
18527 8 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
18528 8 { d_enelistnoabc_proc, 14, 24, 188, 97, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &enemy_dlg_list, NULL, NULL },
18529 8 { jwin_button_proc, 12, 130+10, 109, 21, vc(14), vc(1), 'e', D_EXIT, 0, 0, (void *) "Paste &Enemies", NULL, NULL },
18530 8 { d_dummy_proc, 210, 24, 20, 20, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
18531 8 { jwin_button_proc, 127, 130+10, 42, 21, vc(14), vc(1), 'f', D_EXIT, 0, 0, (void *) "&Flags", NULL, NULL },
18532 8 { jwin_button_proc, 175, 130+10, 53, 21, vc(14), vc(1), 'p', D_EXIT, 0, 0, (void *) "&Pattern", NULL, NULL },
18533 8 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 'c', 0, 0, 0, (void *) close_dlg, NULL, NULL },
18534 8 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 'v', 0, 0, 0, (void *) close_dlg, NULL, NULL },
18535 8 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_DEL, 0, (void *) close_dlg, NULL, NULL },
18536 // 10
18537 8 { jwin_button_proc, 50, 156+10, 61, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
18538 8 { jwin_button_proc, 130, 156+10, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
18539 8 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 27, 0, 0, 0, (void *) close_dlg, NULL, NULL },
18540 8 { jwin_text_proc, 4, 208, 8, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) check, NULL, NULL },
18541 8 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
18542 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
18543 };
18544
18545 int32_t onEnemies()
18546 {
18547 word oldenemy[10];
18548 memcpy(oldenemy,Map.CurrScr()->enemy,10*sizeof(word));
18549 restore_mouse();
18550 char buf[26] = " ";
18551 int32_t ret;
18552 int32_t copy=-1;
18553
18554 build_bie_list(true);
18555
18556 enemy_dlg[0].dp2=get_zc_font(font_lfont);
18557
18558 if(Map.CanPaste())
18559 {
18560 enemy_dlg[3].flags=D_EXIT;
18561 sprintf(buf,"Past&e (from %d:%02X)",(Map.CopyScr()>>8)+1,Map.CopyScr()&255);
18562 }
18563 else
18564 {
18565 enemy_dlg[3].flags=D_DISABLED;
18566 sprintf(buf,"Past&e from screen");
18567 }
18568
18569 enemy_dlg[3].dp=buf;
18570 enemy_dlg[2].d1=0;
18571
18572 do
18573 {
18574 if(copy==-1)
18575 {
18576 enemy_dlg[13].y=zq_screen_h;
18577 }
18578 else
18579 {
18580 enemy_dlg[13].y=(int32_t)((copy<<3)*1.6)+enemy_dlg[2].y+4;
18581 }
18582
18583 large_dialog(enemy_dlg);
18584 // Fix d_enelist_proc
18585 enemy_dlg[2].dp2 = 0;
18586 ((ListData *)enemy_dlg[2].dp)->font = &a4fonts[font_lfont_l];
18587
18588 ret = do_zqdialog(enemy_dlg,2);
18589
18590 switch(ret)
18591 {
18592 case 2:
18593 {
18594 int32_t exit_status;
18595 int32_t i = enemy_dlg[2].d1;
18596 popup_zqdialog_start();
18597 do
18598 {
18599 int32_t enemy = Map.CurrScr()->enemy[i];
18600 enemy = select_enemy("Select Enemy",enemy,true,false,exit_status);
18601
18602 if(enemy>=0)
18603 {
18604 if(exit_status==5 && enemy > 0)
18605 {
18606 edit_enemydata(enemy);
18607 }
18608 else
18609 {
18610 saved=false;
18611 Map.CurrScr()->enemy[i] = enemy;
18612 }
18613 }
18614 }
18615 while(exit_status==5);
18616 popup_zqdialog_end();
18617 }
18618 break;
18619
18620 case 3:
18621 saved=false;
18622 Map.DoPasteScreenCommand(PasteCommandType::ScreenEnemies);
18623 break;
18624
18625 case 5:
18626 onEnemyFlags();
18627 break;
18628
18629 case 6:
18630 onPattern();
18631 break;
18632
18633 case 7:
18634 copy = enemy_dlg[2].d1;
18635 break;
18636
18637 case 8:
18638 saved=false;
18639
18640 if(copy>=0)
18641 {
18642 Map.CurrScr()->enemy[enemy_dlg[2].d1] = Map.CurrScr()->enemy[copy];
18643 }
18644
18645 break;
18646
18647 case 9:
18648 saved=false;
18649 Map.CurrScr()->enemy[enemy_dlg[2].d1] = 0;
18650 break;
18651
18652 case 0:
18653 case 11: //cancel
18654 memcpy(Map.CurrScr()->enemy,oldenemy,10*sizeof(word));
18655 break;
18656
18657 case 10: //ok
18658 {
18659 bool end = false;
18660
18661 for(int32_t i=0; i<10; i++)
18662 {
18663 if(Map.CurrScr()->enemy[i]==0)
18664 end = true;
18665 else if(end)
18666 {
18667 if(jwin_alert("Inactive Enemies","Enemies won't appear if they're preceded"," by '(None)' in the list! Continue?",NULL,"Yes","No",'y','n',get_zc_font(font_lfont))==2)
18668 ret=-1;
18669
18670 break;
18671 }
18672 }
18673
18674 break;
18675 }
18676 }
18677 }
18678 while(ret<10&&ret!=0);
18679
18680 refresh(rALL);
18681 return D_O_K;
18682 }
18683
18684 /*******************************/
18685 /********** onHeader ***********/
18686 /*******************************/
18687
18688 char author[65],title[65],password[32];
18689
18690 int32_t d_showedit_proc(int32_t msg,DIALOG *d,int32_t c)
18691 {
18692 int32_t ret = jwin_edit_proc(msg,d,c);
18693
18694 if(msg==MSG_DRAW)
18695 {
18696 (d+1)->proc(MSG_DRAW,d+1,0);
18697 }
18698
18699 return ret;
18700 }
18701
18702 int32_t onHeader()
18703 {
18704 call_header_dlg();
18705 return D_O_K;
18706 }
18707
18708 void call_cheats_dlg();
18709 int32_t onCheats()
18710 {
18711 call_cheats_dlg();
18712 return D_O_K;
18713 }
18714
18715 bool do_x_button(BITMAP *dest, int32_t x, int32_t y)
18716 {
18717 bool over=false;
18718
18719 while(gui_mouse_b())
18720 {
18721 custom_vsync();
18722
18723 if(isinRect(gui_mouse_x(),gui_mouse_y(),x,y,x+15,y+13))
18724 {
18725 if(!over)
18726 {
18727 draw_x_button(dest, x, y, D_SELECTED);
18728 over=true;
18729 }
18730 }
18731 else
18732 {
18733 if(over)
18734 {
18735 draw_x_button(dest, x, y, 0);
18736 over=false;
18737 }
18738 }
18739 }
18740
18741 return over;
18742 }
18743
18744 bool do_question_button(BITMAP *dest, int32_t x, int32_t y)
18745 {
18746 bool over=false;
18747
18748 while(gui_mouse_b())
18749 {
18750 custom_vsync();
18751
18752 if(isinRect(gui_mouse_x(),gui_mouse_y(),x,y,x+15,y+13))
18753 {
18754 if(!over)
18755 {
18756 draw_question_button(dest, x, y, D_SELECTED);
18757 over=true;
18758 }
18759 }
18760 else
18761 {
18762 if(over)
18763 {
18764 draw_question_button(dest, x, y, 0);
18765 over=false;
18766 }
18767 }
18768 }
18769
18770 return over;
18771 }
18772
18773
18774 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
18775 {
18776 return D_O_K;
18777 }
18778
18779 int32_t d_maptile_proc(int32_t msg, DIALOG *d, int32_t)
18780 {
18781 switch(msg)
18782 {
18783 case MSG_CLICK:
18784 if(select_tile(d->d1,d->d2,1,d->fg,true, 0, true))
18785 return D_REDRAW;
18786
18787 case MSG_DRAW:
18788 {
18789 int32_t dw = d->w;
18790 int32_t dh = d->h;
18791
18792 if(d->dp2==(void*)1)
18793 {
18794 dw /= 2;
18795 dh /= 2;
18796 }
18797
18798 BITMAP *buf = create_bitmap_ex(8,dw,dh);
18799
18800 if(buf)
18801 {
18802 clear_bitmap(buf);
18803
18804 for(int32_t y=0; y<dh; y+=16)
18805 for(int32_t x=0; x<dw; x+=16)
18806 {
18807 if(d->d1)
18808 puttile16(buf,d->d1+(y>>4)*20+(x>>4),x,y,d->fg,0);
18809 }
18810
18811 if(d->dp2==(void*)1)
18812 stretch_blit(buf,screen,0,0,dw,dh,d->x-1,d->y-1,dw*2,dh*2);
18813 else
18814 blit(buf,screen,0,0,d->x,d->y,dw,dh);
18815
18816 destroy_bitmap(buf);
18817 }
18818 }
18819 }
18820
18821 return D_O_K;
18822 }
18823
18824 static int32_t last_combo=0;
18825 static int32_t last_cset=0;
18826
3/4
✓ Branch 0 taken 65536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 65528 times.
✓ Branch 3 taken 8 times.
65536 static combo_alias temp_aliases[MAXCOMBOALIASES];
18827
18828 static char comboa_str_buf[32];
18829
18830 int32_t d_comboalist_proc(int32_t msg,DIALOG *d,int32_t c)
18831 {
18832 int32_t d1 = d->d1;
18833 int32_t ret = jwin_droplist_proc(msg,d,c);
18834 comboa_cnt = d->d1;
18835
18836 if(d1!=d->d1)
18837 {
18838 set_comboaradio(temp_aliases[comboa_cnt].layermask);
18839 return D_REDRAW;
18840 }
18841
18842 return ret;
18843 }
18844
18845 const char *comboalist(int32_t index, int32_t *list_size)
18846 {
18847 if(index>=0)
18848 {
18849 bound(index,0,MAXCOMBOALIASES-1);
18850 sprintf(comboa_str_buf,"%d",index);
18851 return comboa_str_buf;
18852 }
18853
18854 *list_size=MAXCOMBOALIASES;
18855 return NULL;
18856 }
18857
18858 extern int32_t scheme[jcMAX];
18859
18860 int32_t d_comboa_proc(int32_t msg,DIALOG *d,int32_t c)
18861 {
18862 //these are here to bypass compiler warnings about unused arguments
18863 c=c;
18864
18865 combo_alias *combo;
18866 combo = &temp_aliases[comboa_cnt];
18867 int32_t position;
18868 int32_t cur_layer, temp_layer;
18869 int32_t lay_count=0;
18870 int32_t size = 2;
18871
18872 int32_t cx1=(gui_mouse_x()-d->x-(120-(combo->width*8)));
18873 int32_t cy1=(gui_mouse_y()-d->y-(80-(combo->height*8)));
18874 int32_t cx=cx1/(16*size);
18875 int32_t cy=cy1/(16*size);
18876
18877 int32_t co,cs;
18878
18879
18880 switch(msg)
18881 {
18882 case MSG_CLICK:
18883 if((cx>combo->width)||(cx1<0))
18884 return D_O_K;
18885
18886 if((cy>combo->height)||(cy1<0))
18887 return D_O_K;
18888
18889 for(int32_t j=0; j<layer_cnt; j++)
18890 {
18891 if(combo->layermask&(1<<j))
18892 lay_count++;
18893 }
18894
18895 position=(lay_count)*(combo->width+1)*(combo->height+1);
18896 position+=(cy*(combo->width+1))+cx;
18897
18898 if(key[KEY_LSHIFT]||key[KEY_RSHIFT])
18899 {
18900 combo->combos[position] = 0;
18901 combo->csets[position] = 0;
18902
18903 while(gui_mouse_b())
18904 {
18905 /* do nothing */
18906 rest(1);
18907 }
18908
18909 return D_REDRAW;
18910 }
18911
18912 co=combo->combos[position];
18913 cs=combo->csets[position];
18914
18915 if((co==0)||(key[KEY_ZC_LCONTROL]))
18916 {
18917 co=last_combo;
18918 cs=last_cset;
18919 }
18920
18921 if((select_combo_2(co,cs)))
18922 {
18923 last_combo = co;
18924 last_cset = cs;
18925
18926 combo->combos[position]=co;
18927 combo->csets[position]=cs;
18928 }
18929
18930 return D_REDRAW;
18931 break;
18932
18933 case MSG_DRAW:
18934 BITMAP *buf = create_bitmap_ex(8,d->w,d->h);
18935
18936 if(buf)
18937 {
18938 clear_bitmap(buf);
18939
18940 for(int32_t z=0; z<=comboa_lmasktotal(combo->layermask); z++)
18941 {
18942 int32_t k=0;
18943 cur_layer=0;
18944 temp_layer=combo->layermask;
18945
18946 while((temp_layer!=0)&&(k<z))
18947 {
18948 if(temp_layer&1)
18949 {
18950 k++;
18951 }
18952
18953 cur_layer++;
18954 temp_layer = temp_layer>>1;
18955 }
18956
18957 for(int32_t y=0; (y<d->h)&&((y/16)<=combo->height); y+=16)
18958 {
18959 for(int32_t x=0; (x<d->w)&&((x/16)<=combo->width); x+=16)
18960 {
18961 int32_t cpos = (z*(combo->width+1)*(combo->height+1))+(((y/16)*(combo->width+1))+(x/16));
18962
18963 if(combo->combos[cpos])
18964 {
18965 if(!((d-1)->flags&D_SELECTED)||(cur_layer==layer_cnt))
18966 {
18967 if(z==0)
18968 {
18969 puttile16(buf,combobuf[combo->combos[cpos]].tile,x,y,combo->csets[cpos],combobuf[combo->combos[cpos]].flip);
18970 }
18971 else
18972 {
18973 overtile16(buf,combobuf[combo->combos[cpos]].tile,x,y,combo->csets[cpos],combobuf[combo->combos[cpos]].flip);
18974 }
18975 }
18976 }
18977 }
18978 }
18979 }
18980
18981 rectfill(screen, d->x-2,d->y-2,d->x+256+2,d->y+176+2,jwin_pal[jcBOX]);
18982 int32_t dx = 120-(combo->width*8)+d->x;
18983 int32_t dy = 80-(combo->height*8)+d->y;
18984 stretch_blit(buf,screen,0,0,(combo->width+1)*16,(combo->height+1)*16,dx,dy,(combo->width+1)*16*size,(combo->height+1)*16*size);
18985 //blit(buf,screen,0,0,120-(combo->width*8)+d->x,80-(combo->height*8)+d->y,(combo->width+1)*16,(combo->height+1)*16);
18986 (d-11)->w = (combo->width+1)*16*size+2;
18987 (d-11)->h = (combo->height+1)*16*size+2;
18988 (d-11)->x = 120-(combo->width*8)+4*size+2+(d-14)->x;
18989 (d-11)->y = 80-(combo->height*8)+25*size+2+(d-14)->y;
18990 object_message((d-11),MSG_DRAW,0);
18991
18992 destroy_bitmap(buf);
18993 }
18994
18995 break;
18996 }
18997
18998 return D_O_K;
18999 }
19000
19001 void draw_combo_alias_thumbnail(BITMAP *dest, combo_alias const* combo, int32_t x, int32_t y, int32_t size)
19002 {
19003 if(!combo->combo)
19004 {
19005 int32_t cur_layer, temp_layer;
19006
19007 int32_t cw=combo->width+1;
19008 int32_t ch=combo->height+1;
19009 int32_t dw=cw<<4;
19010 int32_t dh=ch<<4;
19011 int32_t sw=16, sh=16, sx=0, sy=0;
19012
19013 if(cw<ch)
19014 {
19015 sw=((cw<<4)/ch);
19016 sx=((16-sw)>>1);
19017 }
19018 else
19019 {
19020 sh=((ch<<4)/cw);
19021 sy=((16-sh)>>1);
19022 }
19023
19024 BITMAP *buf = create_bitmap_ex(8,dw,dh);
19025 BITMAP *buf2 = create_bitmap_ex(8, 16*size, 16*size);
19026 clear_bitmap(buf);
19027 clear_bitmap(buf2);
19028
19029 if(buf&&(combo->width>0||combo->height>0||combo->combos[0]>0))
19030 {
19031 clear_bitmap(buf);
19032
19033 for(int32_t z=0; z<=comboa_lmasktotal(combo->layermask); z++)
19034 {
19035 int32_t k=0;
19036 cur_layer=0;
19037 temp_layer=combo->layermask;
19038
19039 while((temp_layer!=0)&&(k<z))
19040 {
19041 if(temp_layer&1)
19042 {
19043 k++;
19044 }
19045
19046 cur_layer++;
19047 temp_layer = temp_layer>>1;
19048 }
19049
19050 for(int32_t y2=0; (y2<dh)&&((y2>>4)<=combo->height); y2+=16)
19051 {
19052 for(int32_t x2=0; (x2<dw)&&((x2>>4)<=combo->width); x2+=16)
19053 {
19054 int32_t cpos = (z*(combo->width+1)*(combo->height+1))+(((y2/16)*(combo->width+1))+(x2/16));
19055
19056 if(combo->combos[cpos])
19057 {
19058 if(z==0)
19059 {
19060 puttile16(buf,combobuf[combo->combos[cpos]].tile,x2,y2,combo->csets[cpos],combobuf[combo->combos[cpos]].flip);
19061 }
19062 else
19063 {
19064 overtile16(buf,combobuf[combo->combos[cpos]].tile,x2,y2,combo->csets[cpos],combobuf[combo->combos[cpos]].flip);
19065 }
19066 }
19067 }
19068 }
19069 }
19070
19071 stretch_blit(buf, buf2, 0, 0, (cw*16), (ch*16), sx*size, sy*size, sw*size, sh*size);
19072 blit(buf2, dest, 0, 0, x, y, 16*size, 16*size);
19073 }
19074 else
19075 {
19076 rectfill(dest,x,y,x+16*size-1,y+16*size-1,0);
19077 rectfill(dest,x+3*size,y+3*size,x+12*size,y+12*size,vc(4));
19078 }
19079
19080 if(buf)
19081 destroy_bitmap(buf);
19082
19083 if(buf2)
19084 destroy_bitmap(buf2);
19085 }
19086 else
19087 {
19088 if(combobuf[combo->combo].tile>0)
19089 {
19090 rectfill(dest,x,y,x+16*size-1,y+16*size-1,0);
19091 put_combo(dest, x, y, combo->combo, combo->cset, 0, 0, size);
19092 }
19093 else
19094 {
19095 rectfill(dest,x,y,x+16*size-1,y+16*size-1,0);
19096 rectfill(dest,x+3*size,y+3*size,x+12*size,y+12*size,vc(4));
19097 }
19098 }
19099 }
19100
19101 int32_t d_comboat_proc(int32_t msg,DIALOG *d,int32_t)
19102 {
19103 switch(msg)
19104 {
19105 case MSG_CLICK:
19106 {
19107 int32_t c2;
19108 int32_t cs;
19109 c2=temp_aliases[comboa_cnt].combo;
19110 cs=temp_aliases[comboa_cnt].cset;
19111
19112 if(gui_mouse_b()&2) //right mouse button
19113 {
19114 if(c2==0&&cs==0&&!(gui_mouse_b()&1))
19115 {
19116 return D_O_K;
19117 }
19118
19119 temp_aliases[comboa_cnt].combo=0;
19120 temp_aliases[comboa_cnt].cset=0;
19121 }
19122
19123 if(gui_mouse_b()&1) //left mouse button
19124 {
19125 if(select_combo_2(c2, cs))
19126 {
19127 temp_aliases[comboa_cnt].combo=c2;
19128 temp_aliases[comboa_cnt].cset=cs;
19129 }
19130
19131 return D_REDRAW;
19132 }
19133 else
19134 {
19135 return D_REDRAWME;
19136 }
19137 }
19138 break;
19139
19140 case MSG_DRAW:
19141 draw_combo_alias_thumbnail(screen, &temp_aliases[comboa_cnt], d->x-1, d->y-1,2);
19142 break;
19143
19144 default:
19145 break;
19146 }
19147
19148 return D_O_K;
19149 }
19150
19151 int32_t d_comboa_radio_proc(int32_t msg,DIALOG *d,int32_t c);
19152
19153 static DIALOG orgcomboa_dlg[] =
19154 {
19155 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
19156 { jwin_win_proc, 0, 0, 200, 161, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Organize Combo Aliases", NULL, NULL },
19157 { jwin_button_proc, 27, 130, 61, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
19158 { jwin_button_proc, 112, 130, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
19159
19160 { jwin_radio_proc, 10, 40, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void*) "Copy", NULL, NULL },
19161 { jwin_text_proc, 10, 50, 33, 9, 0, 0, 0, 0, 0, 0, (void *) "", NULL, NULL },
19162 // { jwin_radio_proc, 10, 50, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void*) "Move", NULL, NULL },
19163 { jwin_radio_proc, 10, 60, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void*) "Swap", NULL, NULL },
19164 /* 6 */ { jwin_edit_proc, 110, 35, 32, 16, vc(12), vc(1), 0, 0, 4, 0, NULL, NULL, NULL },
19165 { jwin_edit_proc, 110, 55, 32, 16, vc(12), vc(1), 0, 0, 4, 0, NULL, NULL, NULL },
19166 { jwin_text_proc, 60, 40, 80, 8, 0, 0, 0, 0, 0, 0, (void *) "Source", NULL, NULL },
19167 { jwin_text_proc, 60, 60, 80, 8, 0, 0, 0, 0, 0, 0, (void *) "Dest", NULL, NULL},
19168 { jwin_radio_proc, 10, 80, 60, 9, vc(14), vc(1), 0, 0, 0, 0, (void*) "Insert new (before source)", NULL, NULL },
19169 { jwin_radio_proc, 10, 100, 60, 9, vc(14), vc(1), 0, 0, 0, 0, (void*) "Delete source", NULL, NULL },
19170 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
19171 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
19172 };
19173
19174 static DIALOG newcomboa_dlg[] =
19175 {
19176 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
19177 { jwin_win_proc, 0, 0, 200, 161, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Combo Alias Properties", NULL, NULL },
19178 { jwin_button_proc, 27, 130, 61, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
19179 { jwin_button_proc, 112, 130, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
19180 { jwin_text_proc, 24, 34, 80, 8, 0, 0, 0, 0, 0, 0, (void *) "Alias Width", NULL, NULL },
19181 { jwin_text_proc, 24, 52, 80, 8, 0, 0, 0, 0, 0, 0, (void *) "Alias Height", NULL, NULL },
19182 { jwin_text_proc, 24, 70, 100, 8, 0, 0, 0, 0, 0, 0, (void *) "Layers to Draw On:", NULL, NULL },
19183 { jwin_edit_proc, 104, 30, 28-6, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
19184 { jwin_edit_proc, 122, 48, 28-6, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
19185 { jwin_check_proc, 24, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "1", NULL, NULL },
19186 { jwin_check_proc, 50, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "2", NULL, NULL },
19187 { jwin_check_proc, 76, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "3", NULL, NULL },
19188 { jwin_check_proc, 102, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "4", NULL, NULL },
19189 { jwin_check_proc, 128, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "5", NULL, NULL },
19190 { jwin_check_proc, 154, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "6", NULL, NULL },
19191
19192
19193 // { jwin_text_proc, 24, 106, 80, 8, 0, 0, 0, 0, 0, 0, (void *) "Copy to :", NULL, NULL },
19194 //15
19195 // { jwin_edit_proc, 100, 100, 28-6, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
19196 // { jwin_check_proc, 84, 106, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "", NULL, NULL },
19197
19198 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
19199 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
19200 };
19201
19202 bool swapComboAlias(int32_t source, int32_t dest)
19203 {
19204 if(source==dest)
19205 return false;
19206 zc_swap(temp_aliases[source],temp_aliases[dest]);
19207 return true;
19208 }
19209
19210
19211 bool copyComboAlias(int32_t source, int32_t dest)
19212 {
19213 if(source == dest)
19214 return false;
19215 temp_aliases[dest] = temp_aliases[source];
19216 return true;
19217 }
19218
19219 int32_t getcurrentcomboalias();
19220
19221 int32_t onOrgComboAliases()
19222 {
19223 char cSrc[8];
19224 char cDest[8];
19225 sprintf(cSrc,"%d", getcurrentcomboalias());
19226 strcpy(cDest,cSrc);
19227 int32_t iSrc = 0;
19228 int32_t iDest = 0;
19229
19230 //sprintf(cSrc,"0");
19231 //sprintf(cDest,"0");
19232 orgcomboa_dlg[0].dp2=get_zc_font(font_lfont);
19233 orgcomboa_dlg[6].dp= cSrc;
19234 orgcomboa_dlg[7].dp= cDest;
19235 int32_t ret = 1;
19236 large_dialog(orgcomboa_dlg);
19237 do
19238 {
19239 iSrc = atoi((char*)orgcomboa_dlg[6].dp);
19240 iDest = atoi((char*)orgcomboa_dlg[7].dp);
19241 ret = do_zqdialog(orgcomboa_dlg,-1);
19242
19243 if(ret!=1) return ret;
19244
19245 if((atoi((char*) orgcomboa_dlg[6].dp))<0 || (atoi((char*) orgcomboa_dlg[6].dp)) > MAXCOMBOALIASES-1)
19246 {
19247 char buf[100];
19248 snprintf(buf, 100, "Invalid source (range 0-%d)", MAXCOMBOALIASES-1);
19249 buf[99]='\0';
19250 jwin_alert("Error",buf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
19251 ret = 1;
19252 }
19253
19254 // 10,11=ins, del
19255 if(orgcomboa_dlg[10].flags & D_SELECTED) //insert
19256 {
19257 for(int32_t j=MAXCOMBOALIASES-1; j>(atoi((char*) orgcomboa_dlg[6].dp)); --j)
19258 copyComboAlias(j-1,j);
19259 ret = -1;
19260 }
19261
19262 if(orgcomboa_dlg[11].flags & D_SELECTED) //delete
19263 {
19264 for(int32_t j=(atoi((char*) orgcomboa_dlg[6].dp)); j<MAXCOMBOALIASES-1; ++j)
19265 copyComboAlias(j+1,j);
19266 ret = -1;
19267 }
19268
19269 if((atoi((char*) orgcomboa_dlg[6].dp)) == (atoi((char*) orgcomboa_dlg[7].dp)))
19270 {
19271 jwin_alert("Error","Source and dest can't be the same.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
19272 ret = 1;
19273 }
19274
19275 if((atoi((char*) orgcomboa_dlg[7].dp)) < 0 || (atoi((char*) orgcomboa_dlg[7].dp)) > MAXCOMBOALIASES-1)
19276 {
19277 char buf[100];
19278 snprintf(buf, 100, "Invalid dest (range 0-%d)", MAXCOMBOALIASES-1);
19279 buf[99]='\0';
19280
19281 jwin_alert("Error",buf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
19282 ret = 1;
19283 }
19284
19285 if(orgcomboa_dlg[3].flags & D_SELECTED) //copy
19286 {
19287 copyComboAlias((atoi((char*) orgcomboa_dlg[6].dp)),(atoi((char*) orgcomboa_dlg[7].dp)));
19288 ret = -1;
19289 }
19290
19291 if(orgcomboa_dlg[5].flags & D_SELECTED) //swap
19292 {
19293 swapComboAlias((atoi((char*) orgcomboa_dlg[6].dp)),(atoi((char*) orgcomboa_dlg[7].dp)));
19294 ret = -1;
19295 }
19296 }
19297 while(ret==1);
19298 return ret;
19299 }
19300
19301 int32_t onNewComboAlias()
19302 {
19303 combo_alias *combo;
19304 combo = &temp_aliases[comboa_cnt];
19305
19306 char cwidth[5];
19307 char cheight[5];
19308 // char cp[3];
19309
19310 word temp_combos[16*11*7];
19311 byte temp_csets[16*11*7];
19312 sprintf(cwidth, "%d", combo->width+1);
19313 sprintf(cheight, "%d", combo->height+1);
19314 int32_t old_count = (comboa_lmasktotal(combo->layermask)+1)*(combo->width+1)*(combo->height+1);
19315 int32_t old_width=combo->width;
19316 int32_t old_height=combo->height;
19317 int32_t oldlayer=combo->layermask;
19318
19319 for(int32_t i=0; i<old_count; i++)
19320 {
19321 temp_csets[i] = combo->csets[i];
19322 temp_combos[i] = combo->combos[i];
19323 }
19324
19325 newcomboa_dlg[0].dp2 = get_zc_font(font_lfont);
19326 newcomboa_dlg[6].dp = cwidth;
19327 newcomboa_dlg[7].dp = cheight;
19328 newcomboa_dlg[8].flags = (combo->layermask&1)? D_SELECTED : 0;
19329 newcomboa_dlg[9].flags = (combo->layermask&2)? D_SELECTED : 0;
19330 newcomboa_dlg[10].flags = (combo->layermask&4)? D_SELECTED : 0;
19331 newcomboa_dlg[11].flags = (combo->layermask&8)? D_SELECTED : 0;
19332 newcomboa_dlg[12].flags = (combo->layermask&16)? D_SELECTED : 0;
19333 newcomboa_dlg[13].flags = (combo->layermask&32)? D_SELECTED : 0;
19334
19335 large_dialog(newcomboa_dlg);
19336
19337 int32_t ret = do_zqdialog(newcomboa_dlg,-1);
19338
19339 if(ret==1)
19340 {
19341 combo->width = ((atoi(cwidth)-1)<16)?zc_max(0,(atoi(cwidth)-1)):15;
19342 combo->height = ((atoi(cheight)-1)<11)?zc_max(0,(atoi(cheight)-1)):10;
19343 combo->layermask=0;
19344 combo->layermask |= (newcomboa_dlg[8].flags&D_SELECTED)?1:0;
19345 combo->layermask |= (newcomboa_dlg[9].flags&D_SELECTED)?2:0;
19346 combo->layermask |= (newcomboa_dlg[10].flags&D_SELECTED)?4:0;
19347 combo->layermask |= (newcomboa_dlg[11].flags&D_SELECTED)?8:0;
19348 combo->layermask |= (newcomboa_dlg[12].flags&D_SELECTED)?16:0;
19349 combo->layermask |= (newcomboa_dlg[13].flags&D_SELECTED)?32:0;
19350
19351 int32_t new_count = (comboa_lmasktotal(combo->layermask)+1)*(combo->width+1)*(combo->height+1);
19352
19353 combo->combos.clear();
19354 combo->csets.clear();
19355
19356 int32_t j=1;
19357 int32_t old_size=(old_width+1)*(old_height+1);
19358 int32_t new_start[7] =
19359 {
19360 0,
19361 ((combo->width+1)*(combo->height+1)*(1)),
19362 ((combo->width+1)*(combo->height+1)*(2)),
19363 ((combo->width+1)*(combo->height+1)*(3)),
19364 ((combo->width+1)*(combo->height+1)*(4)),
19365 ((combo->width+1)*(combo->height+1)*(5)),
19366 ((combo->width+1)*(combo->height+1)*(6))
19367 };
19368 int32_t new_layers[6] = {0,0,0,0,0,0};
19369 int32_t temp_layer = combo->layermask;
19370 int32_t temp_old = oldlayer;
19371 int32_t old_layers[6] = {0,0,0,0,0,0};
19372 int32_t k=1;
19373
19374 for(int32_t i=0; (i<6)&&(temp_layer!=0); j++,temp_layer>>=1,temp_old>>=1)
19375 {
19376 if(temp_layer&1)
19377 {
19378 new_layers[i] = j;
19379 //if(oldlayer&(1<<(j-1))) old_layers[i] = k++;
19380 i++;
19381 }
19382
19383 if(temp_old&1)
19384 {
19385 if(temp_layer&1)
19386 {
19387 old_layers[i-1] = k;
19388 }
19389
19390 k++;
19391 }
19392 }
19393
19394 for(int32_t i=0; i<new_count; i++)
19395 {
19396 if(i>=new_start[6])
19397 {
19398 //oldl=oldlayer>>(new_layers[5]-1);
19399 j=i-new_start[6];
19400
19401 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[5]-1))))
19402 {
19403 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[5])];
19404 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[5])];
19405 }
19406 else
19407 {
19408 combo->combos[i] = 0;
19409 combo->csets[i] = 0;
19410 }
19411 }
19412 else if(i>=new_start[5])
19413 {
19414 //oldl=oldlayer>>(new_layers[4]-1);
19415 j=i-new_start[5];
19416
19417 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[4]-1))))
19418 {
19419 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[4])];
19420 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[4])];
19421 }
19422 else
19423 {
19424 combo->combos[i] = 0;
19425 combo->csets[i] = 0;
19426 }
19427 }
19428 else if(i>=new_start[4])
19429 {
19430 //oldl=oldlayer>>(new_layers[3]-1);
19431 j=i-new_start[4];
19432
19433 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[3]-1))))
19434 {
19435 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[3])];
19436 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[3])];
19437 }
19438 else
19439 {
19440 combo->combos[i] = 0;
19441 combo->csets[i] = 0;
19442 }
19443 }
19444 else if(i>=new_start[3])
19445 {
19446 //oldl=oldlayer>>(new_layers[2]-1);
19447 j=i-new_start[3];
19448
19449 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[2]-1))))
19450 {
19451 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[2])];
19452 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[2])];
19453 }
19454 else
19455 {
19456 combo->combos[i] = 0;
19457 combo->csets[i] = 0;
19458 }
19459 }
19460 else if(i>=new_start[2])
19461 {
19462 //oldl=oldlayer>>(new_layers[1]-1);
19463 j=i-new_start[2];
19464
19465 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[1]-1))))
19466 {
19467 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[1])];
19468 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[1])];
19469 }
19470 else
19471 {
19472 combo->combos[i] = 0;
19473 combo->csets[i] = 0;
19474 }
19475 }
19476 else if(i>=new_start[1])
19477 {
19478 //oldl=oldlayer>>(new_layers[0]-1);
19479 j=i-new_start[1];
19480
19481 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[0]-1))))
19482 {
19483 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[0])];
19484 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[0])];
19485 }
19486 else
19487 {
19488 combo->combos[i] = 0;
19489 combo->csets[i] = 0;
19490 }
19491 }
19492 else if(i>=new_start[0])
19493 {
19494 if(((i/(combo->width+1))<=old_height)&&((i%(combo->width+1))<=old_width))
19495 {
19496 combo->combos[i] = temp_combos[(i%(combo->width+1))+((old_width+1)*(i/(combo->width+1)))];
19497 combo->csets[i] = temp_csets[(i%(combo->width+1))+((old_width+1)*(i/(combo->width+1)))];
19498 }
19499 else
19500 {
19501 combo->combos[i] = 0;
19502 combo->csets[i] = 0;
19503 }
19504 }
19505 }
19506
19507 set_comboaradio(combo->layermask);
19508 }
19509
19510 return ret;
19511 }
19512
19513 int32_t d_orgcomboa_proc(int32_t msg, DIALOG *d, int32_t c)
19514 {
19515 //these are here to bypass compiler warnings about unused arguments
19516 c=c;
19517
19518 int32_t down=0;
19519 int32_t selected=(d->flags&D_SELECTED)?1:0;
19520 int32_t last_draw;
19521
19522 switch(msg)
19523 {
19524
19525 case MSG_DRAW:
19526 {
19527 FONT *tfont=font;
19528 font=get_zc_font(font_lfont_l);
19529 jwin_draw_text_button(screen, d->x, d->y, d->w, d->h, (char*)d->dp, d->flags, true);
19530 font=tfont;
19531 }
19532 break;
19533
19534 case MSG_WANTFOCUS:
19535 return D_WANTFOCUS;
19536
19537 case MSG_KEY:
19538 /* close dialog? */
19539 onOrgComboAliases();
19540 return D_REDRAW;
19541
19542 /* or just toggle */
19543 /*d->flags ^= D_SELECTED;
19544 object_message(d, MSG_DRAW, 0);
19545 break;*/
19546
19547 case MSG_CLICK:
19548 last_draw = 0;
19549
19550 /* track the mouse until it is released */
19551 while(gui_mouse_b())
19552 {
19553 down = mouse_in_rect(d->x, d->y, d->w, d->h);
19554
19555 /* redraw? */
19556 if(last_draw != down)
19557 {
19558 if(down != selected)
19559 d->flags |= D_SELECTED;
19560 else
19561 d->flags &= ~D_SELECTED;
19562
19563 object_message(d, MSG_DRAW, 0);
19564 last_draw = down;
19565 }
19566
19567 /* let other objects continue to animate */
19568 broadcast_dialog_message(MSG_IDLE, 0);
19569 }
19570
19571 /* redraw in normal state */
19572 if(down)
19573 {
19574 if(d->flags&D_EXIT)
19575 {
19576 d->flags &= ~D_SELECTED;
19577 object_message(d, MSG_DRAW, 0);
19578 }
19579 }
19580
19581 /* should we close the dialog? */
19582 if(down)
19583 {
19584 onOrgComboAliases();
19585 return D_REDRAW;
19586 }
19587
19588 break;
19589 }
19590
19591 return D_O_K;
19592 }
19593
19594 int32_t d_comboabutton_proc(int32_t msg, DIALOG *d, int32_t c)
19595 {
19596 //these are here to bypass compiler warnings about unused arguments
19597 c=c;
19598
19599 int32_t down=0;
19600 int32_t selected=(d->flags&D_SELECTED)?1:0;
19601 int32_t last_draw;
19602
19603 switch(msg)
19604 {
19605
19606 case MSG_DRAW:
19607 {
19608 FONT *tfont=font;
19609 font=get_zc_font(font_lfont_l);
19610 jwin_draw_text_button(screen, d->x, d->y, d->w, d->h, (char*)d->dp, d->flags, true);
19611 font=tfont;
19612 }
19613 break;
19614
19615 case MSG_WANTFOCUS:
19616 return D_WANTFOCUS;
19617
19618 case MSG_KEY:
19619 /* close dialog? */
19620 onNewComboAlias();
19621 return D_REDRAW;
19622
19623 /* or just toggle */
19624 /*d->flags ^= D_SELECTED;
19625 object_message(d, MSG_DRAW, 0);
19626 break;*/
19627
19628 case MSG_CLICK:
19629 last_draw = 0;
19630
19631 /* track the mouse until it is released */
19632 while(gui_mouse_b())
19633 {
19634 down = mouse_in_rect(d->x, d->y, d->w, d->h);
19635
19636 /* redraw? */
19637 if(last_draw != down)
19638 {
19639 if(down != selected)
19640 d->flags |= D_SELECTED;
19641 else
19642 d->flags &= ~D_SELECTED;
19643
19644 object_message(d, MSG_DRAW, 0);
19645 last_draw = down;
19646 }
19647
19648 /* let other objects continue to animate */
19649 broadcast_dialog_message(MSG_IDLE, 0);
19650 }
19651
19652 /* redraw in normal state */
19653 if(down)
19654 {
19655 if(d->flags&D_EXIT)
19656 {
19657 d->flags &= ~D_SELECTED;
19658 object_message(d, MSG_DRAW, 0);
19659 }
19660 }
19661
19662 /* should we close the dialog? */
19663 if(down)
19664 {
19665 onNewComboAlias();
19666 return D_REDRAW;
19667 }
19668
19669 break;
19670 }
19671
19672 return D_O_K;
19673 }
19674
19675 int32_t d_comboacheck_proc(int32_t msg, DIALOG *d, int32_t c)
19676 {
19677 int32_t temp = d->flags&D_SELECTED;
19678 int32_t ret=jwin_checkfont_proc(msg,d,c);
19679
19680 if(temp != (d->flags&D_SELECTED))
19681 {
19682 return D_REDRAW;
19683 }
19684
19685 return ret;
19686 }
19687
19688 8 static ListData comboa_list(comboalist, &font);
19689
19690 static DIALOG editcomboa_dlg[] =
19691 {
19692 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
19693 { jwin_win_proc, 0, 0, 320, 240, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Combo Alias Edit", NULL, NULL },
19694 { jwin_button_proc, 148, 212, 61, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
19695 { jwin_button_proc, 232, 212, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
19696 { jwin_frame_proc, 4+121, 28+81, 1, 1, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
19697 { d_comboabutton_proc, 25, 212, 81, 21, vc(14), vc(1), 'p', D_EXIT, 0, 0, (void *) "&Properties", NULL, NULL },
19698 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
19699 { d_comboa_radio_proc, 285, 44, 30, 8+1, vc(14), vc(1), 0, D_SELECTED, 0, 0, (void *) "0", NULL, NULL },
19700 { d_comboa_radio_proc, 285, 54, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "1", NULL, NULL },
19701 { d_comboa_radio_proc, 285, 64, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "2", NULL, NULL },
19702 { d_comboa_radio_proc, 285, 74, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "3", NULL, NULL },
19703 { d_comboa_radio_proc, 285, 84, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "4", NULL, NULL },
19704
19705 { d_comboa_radio_proc, 285, 94, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "5", NULL, NULL },
19706 { d_comboa_radio_proc, 285, 104, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "6", NULL, NULL },
19707 { d_comboacheck_proc, 285, 164, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
19708 { d_comboa_proc, 6, 27, 256, 176, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
19709 { jwin_ctext_proc, 290, 176, 27, 8, 0, 0, 0, 0, 0, 0, (void *) "Only Show", NULL, NULL },
19710 { jwin_ctext_proc, 290, 186, 27, 8, 0, 0, 0, 0, 0, 0, (void *) "Current", NULL, NULL },
19711 { jwin_ctext_proc, 290, 196, 27, 8, 0, 0, 0, 0, 0, 0, (void *) "Layer", NULL, NULL },
19712 { jwin_ctext_proc, 290, 122, 27, 8, 0, 0, 0, 0, 0, 0, (void *) "Thumbnail", NULL, NULL },
19713 { jwin_frame_proc, 280, 132, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
19714 { d_comboat_proc, 282, 134, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
19715
19716 //21
19717 { d_orgcomboa_proc, 106, 212, 21, 21, vc(14), vc(1), 'p', D_EXIT, 0, 0, (void *) "&Org", NULL, NULL },
19718 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
19719 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
19720 };
19721
19722 int32_t getcurrentcomboalias()
19723 {
19724 return editcomboa_dlg[5].d1;
19725 }
19726
19727 int32_t d_comboa_radio_proc(int32_t msg,DIALOG *d,int32_t c)
19728 {
19729 int32_t temp = layer_cnt;
19730 int32_t ret = jwin_radiofont_proc(msg,d,c);
19731
19732 if(editcomboa_dlg[6].flags&D_SELECTED) layer_cnt=0;
19733 else if(editcomboa_dlg[7].flags&D_SELECTED) layer_cnt=1;
19734 else if(editcomboa_dlg[8].flags&D_SELECTED) layer_cnt=2;
19735 else if(editcomboa_dlg[9].flags&D_SELECTED) layer_cnt=3;
19736 else if(editcomboa_dlg[10].flags&D_SELECTED) layer_cnt=4;
19737 else if(editcomboa_dlg[11].flags&D_SELECTED) layer_cnt=5;
19738 else if(editcomboa_dlg[12].flags&D_SELECTED) layer_cnt=6;
19739
19740 if(temp != layer_cnt)
19741 {
19742 return D_REDRAW;
19743 }
19744
19745 return ret;
19746 }
19747
19748 int32_t set_comboaradio(byte layermask)
19749 {
19750 if(editcomboa_dlg[7].flags&D_SELECTED) editcomboa_dlg[7].flags &= ~D_SELECTED;
19751
19752 if(editcomboa_dlg[8].flags&D_SELECTED) editcomboa_dlg[8].flags &= ~D_SELECTED;
19753
19754 if(editcomboa_dlg[9].flags&D_SELECTED) editcomboa_dlg[9].flags &= ~D_SELECTED;
19755
19756 if(editcomboa_dlg[10].flags&D_SELECTED) editcomboa_dlg[10].flags &= ~D_SELECTED;
19757
19758 if(editcomboa_dlg[11].flags&D_SELECTED) editcomboa_dlg[11].flags &= ~D_SELECTED;
19759
19760 if(editcomboa_dlg[12].flags&D_SELECTED) editcomboa_dlg[12].flags &= ~D_SELECTED;
19761
19762 if(!(layermask&1)) editcomboa_dlg[7].flags |= D_DISABLED;
19763 else editcomboa_dlg[7].flags &= ~D_DISABLED;
19764
19765 if(!(layermask&2)) editcomboa_dlg[8].flags |= D_DISABLED;
19766 else editcomboa_dlg[8].flags &= ~D_DISABLED;
19767
19768 if(!(layermask&4)) editcomboa_dlg[9].flags |= D_DISABLED;
19769 else editcomboa_dlg[9].flags &= ~D_DISABLED;
19770
19771 if(!(layermask&8)) editcomboa_dlg[10].flags |= D_DISABLED;
19772 else editcomboa_dlg[10].flags &= ~D_DISABLED;
19773
19774 if(!(layermask&16)) editcomboa_dlg[11].flags |= D_DISABLED;
19775 else editcomboa_dlg[11].flags &= ~D_DISABLED;
19776
19777 if(!(layermask&32)) editcomboa_dlg[12].flags |= D_DISABLED;
19778 else editcomboa_dlg[12].flags &= ~D_DISABLED;
19779
19780 editcomboa_dlg[6].flags |= D_SELECTED;
19781 layer_cnt=0;
19782 return 1;
19783 }
19784
19785 void call_cpool_dlg(int32_t index);
19786 void call_autocombo_dlg(int32_t index);
19787 int32_t onEditComboPool()
19788 {
19789 call_cpool_dlg(combo_pool_pos);
19790 return D_O_K;
19791 }
19792 int32_t onEditAutoCombo()
19793 {
19794 call_autocombo_dlg(combo_auto_pos);
19795 return D_O_K;
19796 }
19797 int32_t onEditComboAlias()
19798 {
19799 comboa_cnt = combo_apos;
19800 reset_combo_animations();
19801 reset_combo_animations2();
19802
19803 for(int32_t i=0; i<MAXCOMBOALIASES; i++)
19804 temp_aliases[i] = combo_aliases[i];
19805
19806 editcomboa_dlg[0].dp2 = get_zc_font(font_lfont);
19807 set_comboaradio(temp_aliases[comboa_cnt].layermask);
19808 editcomboa_dlg[5].d1 = comboa_cnt;
19809
19810 bool small_d1 = editcomboa_dlg[0].d1==0;
19811 large_dialog(editcomboa_dlg,2);
19812
19813 if(small_d1)
19814 {
19815 for(int32_t i=6; i<=12; i++)
19816 {
19817 editcomboa_dlg[i].w=30*1.5;
19818 editcomboa_dlg[i].h=9*1.5;
19819 }
19820
19821 editcomboa_dlg[13].w=17*1.5;
19822 editcomboa_dlg[13].h=9*1.5;
19823 editcomboa_dlg[4].w=81*1.5;
19824 editcomboa_dlg[4].h=21*1.5;
19825 editcomboa_dlg[4].dp2=get_zc_font(font_lfont_l);
19826 editcomboa_dlg[21].w=21*1.5;
19827 editcomboa_dlg[21].h=21*1.5;
19828 editcomboa_dlg[21].dp2=get_zc_font(font_lfont_l);
19829 }
19830
19831 int32_t ret=do_zqdialog(editcomboa_dlg,-1);
19832
19833 if(ret==1)
19834 {
19835 saved=false;
19836
19837 for(int32_t i=0; i<MAXCOMBOALIASES; i++)
19838 combo_aliases[i] = temp_aliases[i];
19839 }
19840
19841 setup_combo_animations();
19842 setup_combo_animations2();
19843 return D_O_K;
19844 }
19845 void call_calias_dlg(int index)
19846 {
19847 combo_apos = comboa_cnt = index;
19848 onEditComboAlias();
19849 }
19850
19851 static char ffcombo_str_buf[MAXFFCS];
19852 static char fflink_str_buf[MAXFFCS];
19853
19854 BITMAP* ffcur;
19855
19856 const char *ffcombolist(int32_t index, int32_t *list_size)
19857 {
19858 if(index>=0)
19859 {
19860 bound(index,0,MAXFFCS-1);
19861 sprintf(ffcombo_str_buf,"%d",index+1);
19862 return ffcombo_str_buf;
19863 }
19864
19865 *list_size=MAXFFCS;
19866 return NULL;
19867 }
19868
19869 8 static ListData ffcombo_list(ffcombolist, &font);
19870
19871 static DIALOG ffcombo_sel_dlg[] =
19872 {
19873 8 { jwin_win_proc, 0, 0, 200, 179, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Choose Freeform Combo", NULL, NULL },
19874 8 { jwin_button_proc, 35, 152, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Edit", NULL, NULL },
19875 8 { jwin_button_proc, 104, 152, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Done", NULL, NULL },
19876 8 { d_ffcombolist_proc, 11, 24, 49, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 1, 0, (void *) &ffcombo_list, NULL, NULL },
19877 8 { d_comboframe_proc, 68, 23, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
19878 8 { d_bitmap_proc, 70, 25, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
19879 8 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
19880 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
19881 };
19882
19883 int32_t d_ffcombolist_proc(int32_t msg,DIALOG *d,int32_t c)
19884 {
19885 int32_t ret = jwin_droplist_proc(msg,d,c);
19886 int32_t d1 = d->d1;
19887 int32_t x=ffcombo_sel_dlg[0].x;
19888 int32_t y=ffcombo_sel_dlg[0].y;
19889 FONT *tempfont=(font);
19890 int32_t x2=text_length(tempfont, "Move Delay:")+4;
19891
19892 switch(msg)
19893 {
19894 case MSG_DRAW:
19895 if(!ffcur) return D_O_K;
19896
19897 BITMAP *buf = create_bitmap_ex(8,16,16);
19898
19899 if(buf)
19900 {
19901 clear_bitmap(buf);
19902 putcombo(buf,0,0,Map.CurrScr()->ffcs[d1].data,Map.CurrScr()->ffcs[d1].cset);
19903 stretch_blit(buf, ffcur, 0,0, 16, 16, 0, 0, ffcur->w, ffcur->h);
19904 destroy_bitmap(buf);
19905 }
19906
19907 object_message(&ffcombo_sel_dlg[5],MSG_DRAW,0);
19908
19909 int32_t xd = x+int32_t(68*1.5);
19910 int32_t y2 = y+int32_t(55*1.5);
19911 int32_t yd = 9;
19912
19913 rectfill(screen,xd,y2,xd+x2+100,y2+yd*14,jwin_pal[jcBOX]);
19914
19915 textprintf_ex(screen,tempfont,xd,y2,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Combo #:");
19916 textprintf_ex(screen,tempfont,xd+x2,y2,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",Map.CurrScr()->ffcs[d1].data);
19917
19918 textprintf_ex(screen,tempfont,xd,y2+yd,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"CSet #:");
19919 textprintf_ex(screen,tempfont,xd+x2,y2+yd,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",Map.CurrScr()->ffcs[d1].cset);
19920
19921 textprintf_ex(screen,tempfont,xd,y2+yd*2,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"X Pos:");
19922 textprintf_ex(screen,tempfont,xd+x2,y2+yd*2,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%.4f",Map.CurrScr()->ffcs[d1].x.getFloat());
19923
19924 textprintf_ex(screen,tempfont,xd,y2+yd*3,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Y Pos:");
19925 textprintf_ex(screen,tempfont,xd+x2,y2+yd*3,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%.4f",Map.CurrScr()->ffcs[d1].y.getFloat());
19926
19927 textprintf_ex(screen,tempfont,xd,y2+yd*4,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"X Speed:");
19928 textprintf_ex(screen,tempfont,xd+x2,y2+yd*4,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%.4f",Map.CurrScr()->ffcs[d1].vx.getFloat());
19929
19930 textprintf_ex(screen,tempfont,xd,y2+yd*5,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Y Speed:");
19931 textprintf_ex(screen,tempfont,xd+x2,y2+yd*5,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%.4f",Map.CurrScr()->ffcs[d1].vy.getFloat());
19932
19933 textprintf_ex(screen,tempfont,xd,y2+yd*6,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"X Accel:");
19934 textprintf_ex(screen,tempfont,xd+x2,y2+yd*6,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%.4f",Map.CurrScr()->ffcs[d1].ax.getFloat());
19935
19936 textprintf_ex(screen,tempfont,xd,y2+yd*7,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Y Accel:");
19937 textprintf_ex(screen,tempfont,xd+x2,y2+yd*7,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%.4f",Map.CurrScr()->ffcs[d1].ay.getFloat());
19938
19939 textprintf_ex(screen,tempfont,xd,y2+yd*8,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Linked To:");
19940 textprintf_ex(screen,tempfont,xd+x2,y2+yd*8,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",Map.CurrScr()->ffcs[d1].link);
19941
19942 textprintf_ex(screen,tempfont,xd,y2+yd*9,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Move Delay:");
19943 textprintf_ex(screen,tempfont,xd+x2,y2+yd*9,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",Map.CurrScr()->ffcs[d1].delay);
19944
19945 textprintf_ex(screen,tempfont,xd,y2+yd*10,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Combo W:");
19946 textprintf_ex(screen,tempfont,xd+x2,y2+yd*10,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",(Map.CurrScr()->ffEffectWidth(d1)));
19947
19948 textprintf_ex(screen,tempfont,xd,y2+yd*11,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Combo H:");
19949 textprintf_ex(screen,tempfont,xd+x2,y2+yd*11,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",(Map.CurrScr()->ffEffectHeight(d1)));
19950
19951 textprintf_ex(screen,tempfont,xd,y2+yd*12,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Tile W:");
19952 textprintf_ex(screen,tempfont,xd+x2,y2+yd*12,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",(Map.CurrScr()->ffTileWidth(d1)));
19953
19954 textprintf_ex(screen,tempfont,xd,y2+yd*13,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Tile H:");
19955 textprintf_ex(screen,tempfont,xd+x2,y2+yd*13,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",(Map.CurrScr()->ffTileHeight(d1)));
19956
19957 break;
19958 }
19959
19960 return ret;
19961 }
19962 int32_t onSelectFFCombo()
19963 {
19964 ffcombo_sel_dlg[0].dp2 = get_zc_font(font_lfont);
19965 ffcombo_sel_dlg[3].d1 = ff_combo;
19966 ffcur = create_bitmap_ex(8,32,32);
19967
19968 if(!ffcur) return D_O_K;
19969
19970 putcombo(ffcur,0,0,Map.CurrScr()->ffcs[ff_combo].data,Map.CurrScr()->ffcs[ff_combo].cset);
19971 ffcombo_sel_dlg[5].dp = ffcur;
19972
19973 bool resize = !(ffcombo_sel_dlg[0].d1);
19974 large_dialog(ffcombo_sel_dlg);
19975
19976 if(resize)
19977 {
19978 ffcombo_sel_dlg[5].x--;
19979 ffcombo_sel_dlg[5].y--;
19980 }
19981
19982 int32_t ret=do_zqdialog(ffcombo_sel_dlg,0);
19983
19984 while(ret==1)
19985 {
19986 ff_combo = ffcombo_sel_dlg[3].d1;
19987 call_ffc_dialog(ff_combo);
19988 ret=do_zqdialog(ffcombo_sel_dlg,0);
19989 }
19990
19991 destroy_bitmap(ffcur);
19992 return D_O_K;
19993 }
19994
19995 const char *globalscriptlist(int32_t index, int32_t *list_size);
19996 8 static ListData globalscript_list(globalscriptlist, &font);
19997 const char *playerscriptlist(int32_t index, int32_t *list_size);
19998 8 static ListData playerscript_list(playerscriptlist, &font);
19999
20000 const char *ffscriptlist(int32_t index, int32_t *list_size);
20001
20002 8 static ListData ffscript_list(ffscriptlist, &font);
20003
20004 char *strip_decimals(char *string)
20005 {
20006 int32_t len=(int32_t)strlen(string);
20007 char *src=(char *)malloc(len+1);
20008 char *tmpsrc=src;
20009 memcpy(src,string,len+1);
20010 memset(src,0,len+1);
20011
20012 for(size_t i=0; string[i]&&i<=strlen(string); i++)
20013 {
20014 *tmpsrc=string[i];
20015
20016 if(*tmpsrc=='.')
20017 {
20018 while(string[i+1]=='.'&&i<=strlen(string))
20019 {
20020 i++;
20021 }
20022 }
20023
20024 tmpsrc++;
20025 }
20026
20027 memcpy(string,src,len);
20028 free(src);
20029 return string;
20030 }
20031
20032 // Unused??? -L 6/6/11
20033 char *clean_numeric_string(char *string)
20034 {
20035 bool found_sign=false;
20036 bool found_decimal=false;
20037 int32_t len=(int32_t)strlen(string);
20038 char *src=(char *)malloc(len+1);
20039 char *tmpsrc=src;
20040 memcpy(src,string,len+1);
20041 memset(src,0,len+1);
20042
20043 // strip out non-numerical characters
20044 for(size_t i=0; string[i]&&i<=strlen(string); i++)
20045 {
20046 *tmpsrc=string[i];
20047
20048 if(*tmpsrc!='.'&&*tmpsrc!='-'&&*tmpsrc!='+'&&!isdigit(*tmpsrc))
20049 {
20050 while(*tmpsrc!='.'&&*tmpsrc!='-'&&*tmpsrc!='+'&&!isdigit(*tmpsrc))
20051 {
20052 i++;
20053 }
20054 }
20055
20056 tmpsrc++;
20057 }
20058
20059 len=(int32_t)strlen(src);
20060 char *src2=(char *)malloc(len+1);
20061 tmpsrc=src2;
20062 memcpy(src,src2,len+1);
20063 memset(src2,0,len+1);
20064
20065 // second purge
20066 for(size_t i=0; src[i]&&i<=strlen(src); i++)
20067 {
20068 *tmpsrc=src[i];
20069
20070 if(*tmpsrc=='-'||*tmpsrc=='+')
20071 {
20072 if(found_sign||found_decimal)
20073 {
20074 while(*tmpsrc=='-'||*tmpsrc=='+')
20075 {
20076 i++;
20077 }
20078 }
20079
20080 found_sign=true;
20081 }
20082
20083 if(*tmpsrc=='.')
20084 {
20085 if(found_decimal)
20086 {
20087 while(*tmpsrc=='.')
20088 {
20089 i++;
20090 }
20091 }
20092
20093 found_decimal=true;
20094 }
20095
20096 tmpsrc++;
20097 }
20098
20099 sprintf(string, "%s", src2);
20100 free(src);
20101 free(src2);
20102 return string;
20103 }
20104
20105 script_struct biglobal[NUMSCRIPTGLOBAL+1]; //global script
20106 int32_t biglobal_cnt = -1;
20107 script_struct biffs[NUMSCRIPTFFC]; //ff script
20108 int32_t biffs_cnt = -1;
20109 script_struct biitems[NUMSCRIPTITEM]; //item script
20110 int32_t biitems_cnt = -1;
20111 script_struct binpcs[NUMSCRIPTGUYS]; //npc script
20112 int32_t binpcs_cnt = -1;
20113
20114 script_struct bilweapons[NUMSCRIPTWEAPONS]; //lweapon script
20115 int32_t bilweapons_cnt = -1;
20116
20117 script_struct bieweapons[NUMSCRIPTWEAPONS]; //eweapon script
20118 int32_t bieweapons_cnt = -1;
20119
20120 script_struct bihero[NUMSCRIPTPLAYER]; //link script
20121 int32_t bihero_cnt = -1;
20122
20123 script_struct biscreens[NUMSCRIPTSCREEN]; //screen (screendata) script
20124 int32_t biscreens_cnt = -1;
20125
20126 script_struct bidmaps[NUMSCRIPTSDMAP]; //dmap (dmapdata) script
20127 int32_t bidmaps_cnt = -1;
20128
20129 script_struct biditemsprites[NUMSCRIPTSITEMSPRITE]; //dmap (dmapdata) script
20130 int32_t biitemsprites_cnt = -1;
20131
20132 script_struct bidcomboscripts[NUMSCRIPTSCOMBODATA]; //dmap (dmapdata) script
20133 int32_t bidcomboscripts_cnt = -1;
20134 //static char ffscript_str_buf[32];
20135
20136 void build_biglobal_list()
20137 {
20138 biglobal[0].first = "(None)";
20139 biglobal[0].second = -1;
20140 biglobal_cnt = 1;
20141
20142 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
20143 {
20144 if(globalmap[i].scriptname.length()==0)
20145 continue;
20146
20147 stringstream ss;
20148 ss << globalmap[i].scriptname << " (" << i << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
20149 biglobal[biglobal_cnt].first = ss.str();
20150 biglobal[biglobal_cnt].second = i;
20151 ++biglobal_cnt;
20152 }
20153
20154 // Blank out the rest of the list
20155 for(int32_t i=biglobal_cnt; i<NUMSCRIPTGLOBAL; ++i)
20156 {
20157 biglobal[i].first="";
20158 biglobal[i].second=-1;
20159 }
20160
20161 //Bubble sort! (doesn't account for gaps between scripts)
20162 for(int32_t i = 0; i < biglobal_cnt - 1; i++)
20163 {
20164 for(int32_t j = i + 1; j < biglobal_cnt; j++)
20165 {
20166 if(stricmp(biglobal[i].first.c_str(),biglobal[j].first.c_str()) > 0 && strcmp(biglobal[j].first.c_str(),""))
20167 zc_swap(biglobal[i],biglobal[j]);
20168 }
20169 }
20170
20171 biglobal_cnt = 0;
20172
20173 for(int32_t i = 0; i < NUMSCRIPTGLOBAL+1; ++i)
20174 if(biglobal[i].first.length() > 0)
20175 biglobal_cnt = i+1;
20176 }
20177
20178 3 void build_biffs_list()
20179 {
20180 3 biffs[0].first = "(None)";
20181 3 biffs[0].second = -1;
20182 3 biffs_cnt = 1;
20183
20184
2/2
✓ Branch 0 taken 1533 times.
✓ Branch 1 taken 3 times.
1536 for(int32_t i = 0; i < NUMSCRIPTFFC - 1; i++)
20185 {
20186
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 1469 times.
1533 if(ffcmap[i].scriptname.length()==0)
20187 1469 continue;
20188
20189 64 stringstream ss;
20190
5/10
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 64 times.
✗ Branch 9 not taken.
64 ss << ffcmap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
20191
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 biffs[biffs_cnt].first = ss.str();
20192 64 biffs[biffs_cnt].second = i;
20193 64 biffs_cnt++;
20194 64 }
20195
20196 // Blank out the rest of the list
20197
2/2
✓ Branch 0 taken 1469 times.
✓ Branch 1 taken 3 times.
1472 for(int32_t i=biffs_cnt; i<NUMSCRIPTFFC; i++)
20198 {
20199 1469 biffs[i].first="";
20200 1469 biffs[i].second=-1;
20201 1469 }
20202
20203 //Bubble sort! (doesn't account for gaps between scripts)
20204
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 3 times.
67 for(int32_t i = 0; i < biffs_cnt - 1; i++)
20205 {
20206
2/2
✓ Branch 0 taken 1273 times.
✓ Branch 1 taken 64 times.
1337 for(int32_t j = i + 1; j < biffs_cnt; j++)
20207 {
20208
3/4
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 745 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528 times.
1273 if(stricmp(biffs[i].first.c_str(),biffs[j].first.c_str()) > 0 && strcmp(biffs[j].first.c_str(),""))
20209 528 zc_swap(biffs[i],biffs[j]);
20210 1273 }
20211 64 }
20212
20213 3 biffs_cnt = 0;
20214
20215
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 3 times.
1539 for(int32_t i = 0; i < NUMSCRIPTFFC; i++)
20216
2/2
✓ Branch 0 taken 1469 times.
✓ Branch 1 taken 67 times.
1603 if(biffs[i].first.length() > 0)
20217 67 biffs_cnt = i+1;
20218 3 }
20219
20220 //npc scripts
20221 void build_binpcs_list()
20222 {
20223 binpcs[0].first = "(None)";
20224 binpcs[0].second = -1;
20225 binpcs_cnt = 1;
20226
20227 for(int32_t i = 0; i < NUMSCRIPTGUYS - 1; i++)
20228 {
20229 if(npcmap[i].scriptname.length()==0)
20230 continue;
20231
20232 stringstream ss;
20233 ss << npcmap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
20234 binpcs[binpcs_cnt].first = ss.str();
20235 binpcs[binpcs_cnt].second = i;
20236 binpcs_cnt++;
20237 }
20238
20239 // Blank out the rest of the list
20240 for(int32_t i=binpcs_cnt; i<NUMSCRIPTGUYS; i++)
20241 {
20242 binpcs[i].first="";
20243 binpcs[i].second=-1;
20244 }
20245
20246 //Bubble sort! (doesn't account for gaps between scripts)
20247 for(int32_t i = 0; i < binpcs_cnt - 1; i++)
20248 {
20249 for(int32_t j = i + 1; j < binpcs_cnt; j++)
20250 {
20251 if(stricmp(binpcs[i].first.c_str(),binpcs[j].first.c_str()) > 0 && strcmp(binpcs[j].first.c_str(),""))
20252 zc_swap(binpcs[i],binpcs[j]);
20253 }
20254 }
20255
20256 binpcs_cnt = 0;
20257
20258 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
20259 if(binpcs[i].first.length() > 0)
20260 binpcs_cnt = i+1;
20261 }
20262
20263
20264 //lweapon scripts
20265 void build_bilweapons_list()
20266 {
20267 bilweapons[0].first = "(None)";
20268 bilweapons[0].second = -1;
20269 bilweapons_cnt = 1;
20270
20271 for(int32_t i = 0; i < NUMSCRIPTWEAPONS - 1; i++)
20272 {
20273 if(lwpnmap[i].scriptname.length()==0)
20274 continue;
20275
20276 stringstream ss;
20277 ss << lwpnmap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
20278 bilweapons[bilweapons_cnt].first = ss.str();
20279 bilweapons[bilweapons_cnt].second = i;
20280 bilweapons_cnt++;
20281 }
20282
20283 // Blank out the rest of the list
20284 for(int32_t i=bilweapons_cnt; i<NUMSCRIPTWEAPONS; i++)
20285 {
20286 bilweapons[i].first="";
20287 bilweapons[i].second=-1;
20288 }
20289
20290 //Bubble sort! (doesn't account for gaps between scripts)
20291 for(int32_t i = 0; i < bilweapons_cnt - 1; i++)
20292 {
20293 for(int32_t j = i + 1; j < bilweapons_cnt; j++)
20294 {
20295 if(stricmp(bilweapons[i].first.c_str(),bilweapons[j].first.c_str()) > 0 && strcmp(bilweapons[j].first.c_str(),""))
20296 zc_swap(bilweapons[i],bilweapons[j]);
20297 }
20298 }
20299
20300 bilweapons_cnt = 0;
20301
20302 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
20303 if(bilweapons[i].first.length() > 0)
20304 bilweapons_cnt = i+1;
20305 }
20306
20307 //eweapon scripts
20308 void build_bieweapons_list()
20309 {
20310 bieweapons[0].first = "(None)";
20311 bieweapons[0].second = -1;
20312 bieweapons_cnt = 1;
20313
20314 for(int32_t i = 0; i < NUMSCRIPTWEAPONS - 1; i++)
20315 {
20316 if(ewpnmap[i].scriptname.length()==0)
20317 continue;
20318
20319 stringstream ss;
20320 ss << ewpnmap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
20321 bieweapons[bieweapons_cnt].first = ss.str();
20322 bieweapons[bieweapons_cnt].second = i;
20323 bieweapons_cnt++;
20324 }
20325
20326 // Blank out the rest of the list
20327 for(int32_t i=bieweapons_cnt; i<NUMSCRIPTWEAPONS; i++)
20328 {
20329 bieweapons[i].first="";
20330 bieweapons[i].second=-1;
20331 }
20332
20333 //Bubble sort! (doesn't account for gaps between scripts)
20334 for(int32_t i = 0; i < bieweapons_cnt - 1; i++)
20335 {
20336 for(int32_t j = i + 1; j < bieweapons_cnt; j++)
20337 {
20338 if(stricmp(bieweapons[i].first.c_str(),bieweapons[j].first.c_str()) > 0 && strcmp(bieweapons[j].first.c_str(),""))
20339 zc_swap(bieweapons[i],bieweapons[j]);
20340 }
20341 }
20342
20343 bieweapons_cnt = 0;
20344
20345 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
20346 if(bieweapons[i].first.length() > 0)
20347 bieweapons_cnt = i+1;
20348 }
20349
20350 //player scripts
20351 void build_bihero_list()
20352 {
20353 bihero[0].first = "(None)";
20354 bihero[0].second = -1;
20355 bihero_cnt = 1;
20356
20357 for(int32_t i = 0; i < NUMSCRIPTPLAYER - 1; i++)
20358 {
20359 if(playermap[i].scriptname.length()==0)
20360 continue;
20361
20362 stringstream ss;
20363 ss << playermap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
20364 bihero[bihero_cnt].first = ss.str();
20365 bihero[bihero_cnt].second = i;
20366 bihero_cnt++;
20367 }
20368
20369 // Blank out the rest of the list
20370 for(int32_t i=bihero_cnt; i<NUMSCRIPTPLAYER; i++)
20371 {
20372 bihero[i].first="";
20373 bihero[i].second=-1;
20374 }
20375
20376 //Bubble sort! (doesn't account for gaps between scripts)
20377 for(int32_t i = 0; i < bihero_cnt - 1; i++)
20378 {
20379 for(int32_t j = i + 1; j < bihero_cnt; j++)
20380 {
20381 if(stricmp(bihero[i].first.c_str(),bihero[j].first.c_str()) > 0 && strcmp(bihero[j].first.c_str(),""))
20382 zc_swap(bihero[i],bihero[j]);
20383 }
20384 }
20385
20386 bihero_cnt = 0;
20387
20388 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
20389 if(bihero[i].first.length() > 0)
20390 bihero_cnt = i+1;
20391 }
20392
20393 //dmap scripts
20394 void build_bidmaps_list()
20395 {
20396 bidmaps[0].first = "(None)";
20397 bidmaps[0].second = -1;
20398 bidmaps_cnt = 1;
20399
20400 for(int32_t i = 0; i < NUMSCRIPTSDMAP - 1; i++)
20401 {
20402 if(dmapmap[i].scriptname.length()==0)
20403 continue;
20404
20405 stringstream ss;
20406 ss << dmapmap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
20407 bidmaps[bidmaps_cnt].first = ss.str();
20408 bidmaps[bidmaps_cnt].second = i;
20409 bidmaps_cnt++;
20410 }
20411
20412 // Blank out the rest of the list
20413 for(int32_t i=bidmaps_cnt; i<NUMSCRIPTSDMAP; i++)
20414 {
20415 bidmaps[i].first="";
20416 bidmaps[i].second=-1;
20417 }
20418
20419 //Bubble sort! (doesn't account for gaps between scripts)
20420 for(int32_t i = 0; i < bidmaps_cnt - 1; i++)
20421 {
20422 for(int32_t j = i + 1; j < bidmaps_cnt; j++)
20423 {
20424 if(stricmp(bidmaps[i].first.c_str(),bidmaps[j].first.c_str()) > 0 && strcmp(bidmaps[j].first.c_str(),""))
20425 zc_swap(bidmaps[i],bidmaps[j]);
20426 }
20427 }
20428
20429 bidmaps_cnt = 0;
20430
20431 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
20432 if(bidmaps[i].first.length() > 0)
20433 bidmaps_cnt = i+1;
20434 }
20435
20436 //screen scripts
20437 void build_biscreens_list()
20438 {
20439 biscreens[0].first = "(None)";
20440 biscreens[0].second = -1;
20441 biscreens_cnt = 1;
20442
20443 for(int32_t i = 0; i < NUMSCRIPTSCREEN - 1; i++)
20444 {
20445 if(screenmap[i].scriptname.length()==0)
20446 continue;
20447
20448 stringstream ss;
20449 ss << screenmap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
20450 biscreens[biscreens_cnt].first = ss.str();
20451 biscreens[biscreens_cnt].second = i;
20452 biscreens_cnt++;
20453 }
20454
20455 // Blank out the rest of the list
20456 for(int32_t i=biscreens_cnt; i<NUMSCRIPTSCREEN; i++)
20457 {
20458 biscreens[i].first="";
20459 biscreens[i].second=-1;
20460 }
20461
20462 //Bubble sort! (doesn't account for gaps between scripts)
20463 for(int32_t i = 0; i < biscreens_cnt - 1; i++)
20464 {
20465 for(int32_t j = i + 1; j < biscreens_cnt; j++)
20466 {
20467 if(stricmp(biscreens[i].first.c_str(),biscreens[j].first.c_str()) > 0 && strcmp(biscreens[j].first.c_str(),""))
20468 zc_swap(biscreens[i],biscreens[j]);
20469 }
20470 }
20471
20472 biscreens_cnt = 0;
20473
20474 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
20475 if(biscreens[i].first.length() > 0)
20476 biscreens_cnt = i+1;
20477 }
20478
20479 //screen scripts
20480 void build_biitemsprites_list()
20481 {
20482 biditemsprites[0].first = "(None)";
20483 biditemsprites[0].second = -1;
20484 biitemsprites_cnt = 1;
20485
20486 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE - 1; i++)
20487 {
20488 if(itemspritemap[i].scriptname.length()==0)
20489 continue;
20490
20491 stringstream ss;
20492 ss << itemspritemap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
20493 biditemsprites[biitemsprites_cnt].first = ss.str();
20494 biditemsprites[biitemsprites_cnt].second = i;
20495 biitemsprites_cnt++;
20496 }
20497
20498 // Blank out the rest of the list
20499 for(int32_t i=biitemsprites_cnt; i<NUMSCRIPTSITEMSPRITE; i++)
20500 {
20501 biditemsprites[i].first="";
20502 biditemsprites[i].second=-1;
20503 }
20504
20505 //Bubble sort! (doesn't account for gaps between scripts)
20506 for(int32_t i = 0; i < biitemsprites_cnt - 1; i++)
20507 {
20508 for(int32_t j = i + 1; j < biitemsprites_cnt; j++)
20509 {
20510 if(stricmp(biditemsprites[i].first.c_str(),biditemsprites[j].first.c_str()) > 0 && strcmp(biditemsprites[j].first.c_str(),""))
20511 zc_swap(biditemsprites[i],biditemsprites[j]);
20512 }
20513 }
20514
20515 biitemsprites_cnt = 0;
20516
20517 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
20518 if(biditemsprites[i].first.length() > 0)
20519 biitemsprites_cnt = i+1;
20520 }
20521
20522 3 void build_biitems_list()
20523 {
20524 3 biitems[0].first = "(None)";
20525 3 biitems[0].second = -1;
20526 3 biitems_cnt = 1;
20527
20528
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 for(int32_t i = 0; i < NUMSCRIPTITEM - 1; i++, biitems_cnt++)
20529 {
20530 765 stringstream ss;
20531
20532
4/6
✓ Branch 0 taken 765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 765 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
✓ Branch 5 taken 754 times.
765 if(!itemmap[i].isEmpty())
20533
5/10
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 11 times.
✗ Branch 9 not taken.
11 ss << itemmap[i].scriptname << " (" << i+1 << ")";
20534
20535
1/2
✓ Branch 0 taken 765 times.
✗ Branch 1 not taken.
765 biitems[biitems_cnt].first = ss.str();
20536 765 biitems[biitems_cnt].second = i;
20537 765 }
20538
20539
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 for(int32_t i = 0; i < biitems_cnt - 1; i++)
20540 {
20541
2/2
✓ Branch 0 taken 97920 times.
✓ Branch 1 taken 765 times.
98685 for(int32_t j = i + 1; j < biitems_cnt; j++)
20542 {
20543
4/4
✓ Branch 0 taken 3489 times.
✓ Branch 1 taken 94431 times.
✓ Branch 2 taken 3486 times.
✓ Branch 3 taken 3 times.
97920 if(stricmp(biitems[i].first.c_str(), biitems[j].first.c_str()) > 0 && strcmp(biitems[j].first.c_str(),""))
20544 3 zc_swap(biitems[i], biitems[j]);
20545 97920 }
20546 765 }
20547
20548 3 biitems_cnt = 0;
20549
20550
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 3 times.
771 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
20551
2/2
✓ Branch 0 taken 754 times.
✓ Branch 1 taken 14 times.
782 if(biitems[i].first.length() > 0)
20552 14 biitems_cnt = i+1;
20553 3 }
20554
20555
20556 //dmap scripts
20557 void build_bidcomboscripts_list()
20558 {
20559 bidcomboscripts[0].first = "(None)";
20560 bidcomboscripts[0].second = -1;
20561 bidcomboscripts_cnt = 1;
20562
20563 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA - 1; i++)
20564 {
20565 if(comboscriptmap[i].scriptname.length()==0)
20566 continue;
20567
20568 stringstream ss;
20569 ss << comboscriptmap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
20570 bidcomboscripts[bidcomboscripts_cnt].first = ss.str();
20571 bidcomboscripts[bidcomboscripts_cnt].second = i;
20572 bidcomboscripts_cnt++;
20573 }
20574
20575 // Blank out the rest of the list
20576 for(int32_t i=bidcomboscripts_cnt; i<NUMSCRIPTSCOMBODATA; i++)
20577 {
20578 bidcomboscripts[i].first="";
20579 bidcomboscripts[i].second=-1;
20580 }
20581
20582 //Bubble sort! (doesn't account for gaps between scripts)
20583 for(int32_t i = 0; i < bidcomboscripts_cnt - 1; i++)
20584 {
20585 for(int32_t j = i + 1; j < bidcomboscripts_cnt; j++)
20586 {
20587 if(stricmp(bidcomboscripts[i].first.c_str(),bidcomboscripts[j].first.c_str()) > 0 && strcmp(bidcomboscripts[j].first.c_str(),""))
20588 zc_swap(bidcomboscripts[i],bidcomboscripts[j]);
20589 }
20590 }
20591
20592 bidcomboscripts_cnt = 0;
20593
20594 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
20595 if(bidcomboscripts[i].first.length() > 0)
20596 bidcomboscripts_cnt = i+1;
20597 }
20598
20599
20600 const char *globalscriptlist(int32_t index, int32_t *list_size)
20601 {
20602 if(index < 0)
20603 {
20604 *list_size = biglobal_cnt;
20605 return NULL;
20606 }
20607
20608 return biglobal[index].first.c_str();
20609 }
20610
20611 const char *ffscriptlist(int32_t index, int32_t *list_size)
20612 {
20613 if(index < 0)
20614 {
20615 *list_size = biffs_cnt;
20616 return NULL;
20617 }
20618
20619 return biffs[index].first.c_str();
20620 }
20621
20622 const char *playerscriptlist(int32_t index, int32_t *list_size)
20623 {
20624 if(index < 0)
20625 {
20626 *list_size = bihero_cnt;
20627 return NULL;
20628 }
20629
20630 return bihero[index].first.c_str();
20631 }
20632
20633 const char *lweaponscriptlist(int32_t index, int32_t *list_size)
20634 {
20635 if(index < 0)
20636 {
20637 *list_size = bilweapons_cnt;
20638 return NULL;
20639 }
20640
20641 return bilweapons[index].first.c_str();
20642 }
20643
20644 const char *npcscriptlist(int32_t index, int32_t *list_size)
20645 {
20646 if(index < 0)
20647 {
20648 *list_size = binpcs_cnt;
20649 return NULL;
20650 }
20651
20652 return binpcs[index].first.c_str();
20653 }
20654
20655 static char itemscript_str_buf[32];
20656
20657 char *itemscriptlist(int32_t index, int32_t *list_size)
20658 {
20659 if(index>=0)
20660 {
20661 bound(index,0,255);
20662 sprintf(itemscript_str_buf,"%d: %s",index, ffcmap[index-1].scriptname.c_str());
20663 return itemscript_str_buf;
20664 }
20665
20666 *list_size=256;
20667 return NULL;
20668 }
20669
20670 static char ffscript_str_buf2[32];
20671
20672 const char *ffscriptlist2(int32_t index, int32_t *list_size)
20673 {
20674 if(index>=0)
20675 {
20676 char buf[20];
20677 bound(index,0,510);
20678
20679 if(ffcmap[index].scriptname=="")
20680 strcpy(buf, "<none>");
20681 else
20682 {
20683 strncpy(buf, ffcmap[index].scriptname.c_str(), 19);
20684 buf[19]='\0';
20685 }
20686
20687 sprintf(ffscript_str_buf2,"%d: %s",index+1, buf);
20688 return ffscript_str_buf2;
20689 }
20690
20691 *list_size=511;
20692 return NULL;
20693 }
20694
20695 static char itemscript_str_buf2[32];
20696
20697 const char *itemscriptlist2(int32_t index, int32_t *list_size)
20698 {
20699 if(index>=0)
20700 {
20701 char buf[20];
20702 bound(index,0,254);
20703
20704 if(itemmap[index].scriptname=="")
20705 strcpy(buf, "<none>");
20706 else
20707 {
20708 strncpy(buf, itemmap[index].scriptname.c_str(), 19);
20709 buf[19]='\0';
20710 }
20711
20712 sprintf(itemscript_str_buf2,"%d: %s",index+1, buf);
20713 return itemscript_str_buf2;
20714 }
20715
20716 *list_size=255;
20717 return NULL;
20718 }
20719
20720
20721 static char comboscript_str_buf2[32];
20722 const char *comboscriptlist2(int32_t index, int32_t *list_size)
20723 {
20724 if(index>=0)
20725 {
20726 char buf[20];
20727 bound(index,0,254);
20728
20729 if(comboscriptmap[index].scriptname=="")
20730 strcpy(buf, "<none>");
20731 else
20732 {
20733 strncpy(buf, comboscriptmap[index].scriptname.c_str(), 19);
20734 buf[19]='\0';
20735 }
20736
20737 sprintf(comboscript_str_buf2,"%d: %s",index+1, buf);
20738 return comboscript_str_buf2;
20739 }
20740
20741 *list_size=255;
20742 return NULL;
20743 }
20744
20745 static char gscript_str_buf2[40];
20746
20747 const char *gscriptlist2(int32_t index, int32_t *list_size)
20748 {
20749 if(index >= 0)
20750 {
20751 bound(index,0,3);
20752
20753 char buf[20];
20754
20755 if(globalmap[index].scriptname == "")
20756 strcpy(buf, "<none>");
20757 else
20758 {
20759 strncpy(buf, globalmap[index].scriptname.c_str(), 19);
20760 buf[19]='\0';
20761 }
20762
20763 switch(index)
20764 {
20765 case GLOBAL_SCRIPT_INIT:
20766 sprintf(gscript_str_buf2,"Initialization: %s", buf); break;
20767 case GLOBAL_SCRIPT_GAME:
20768 sprintf(gscript_str_buf2,"Active: %s", buf); break;
20769 case GLOBAL_SCRIPT_END:
20770 sprintf(gscript_str_buf2,"onExit: %s", buf); break;
20771 case GLOBAL_SCRIPT_ONSAVELOAD:
20772 sprintf(gscript_str_buf2,"onSaveLoad: %s", buf); break;
20773 case GLOBAL_SCRIPT_ONLAUNCH:
20774 sprintf(gscript_str_buf2,"onLaunch: %s", buf); break;
20775 case GLOBAL_SCRIPT_ONCONTGAME:
20776 sprintf(gscript_str_buf2,"onContGame: %s", buf); break;
20777 case GLOBAL_SCRIPT_F6:
20778 sprintf(gscript_str_buf2,"onF6Menu: %s", buf); break;
20779 case GLOBAL_SCRIPT_ONSAVE:
20780 sprintf(gscript_str_buf2,"onSave: %s", buf); break;
20781 }
20782
20783 return gscript_str_buf2;
20784 }
20785
20786 if(list_size != NULL)
20787 *list_size=4;
20788
20789 return NULL;
20790 }
20791
20792 static int32_t as_ffc_list[] = { 4, 5, 6, -1};
20793 static int32_t as_global_list[] = { 7, 8, 9, -1}; //Why does putting 15 in here not place my message only on the global tab? ~Joe
20794 static int32_t as_item_list[] = { 10, 11, 12, -1};
20795 static int32_t as_npc_list[] = { 18, 19, 20, -1}; //npc scripts TAB
20796 static int32_t as_lweapon_list[] = { 21, 22, 23, -1}; //lweapon scripts TAB
20797 static int32_t as_eweapon_list[] = { 24, 25, 26, -1}; //eweapon scripts TAB
20798 static int32_t as_hero_list[] = { 27, 28, 29, -1}; //player scripts TAB
20799 static int32_t as_screen_list[] = { 30, 31, 32, -1}; //screendata scripts TAB
20800 static int32_t as_dmap_list[] = { 33, 34, 35, -1}; //dmapdata scripts TAB
20801 static int32_t as_itemsprite_list[] = { 36, 37, 38, -1}; //dmapdata scripts TAB
20802 static int32_t as_comboscript_list[] = { 39, 40, 41, -1}; //combodata scripts TAB
20803 static int32_t as_genericscript_list[] = { 45, 46, 47, -1}; //generic scripts TAB
20804 static int32_t as_subscreenscript_list[] = { 48, 49, 50, -1}; //generic scripts TAB
20805
20806 static TABPANEL assignscript_tabs[] =
20807 {
20808 // (text)
20809 { (char *)"FFC", D_SELECTED, as_ffc_list, 0, NULL },
20810 { (char *)"Global", 0, as_global_list, 0, NULL },
20811 { (char *)"Item", 0, as_item_list, 0, NULL },
20812 { (char *)"NPC", 0, as_npc_list, 0, NULL },
20813 { (char *)"LWeapon", 0, as_lweapon_list, 0, NULL },
20814 { (char *)"EWeapon", 0, as_eweapon_list, 0, NULL },
20815 { (char *)"Hero", 0, as_hero_list, 0, NULL },
20816 { (char *)"DMap", 0, as_dmap_list, 0, NULL },
20817 { (char *)"Screen", 0, as_screen_list, 0, NULL },
20818 { (char *)"Item Sprite", 0, as_itemsprite_list, 0, NULL },
20819 { (char *)"Combo", 0, as_comboscript_list, 0, NULL },
20820 { (char *)"Generic", 0, as_genericscript_list, 0, NULL },
20821 { (char *)"Subscreen", 0, as_subscreenscript_list, 0, NULL },
20822 { NULL, 0, NULL, 0, NULL }
20823 };
20824
20825 const char *assignffclist(int32_t index, int32_t *list_size)
20826 {
20827 if(index<0)
20828 {
20829 *list_size = (int32_t)ffcmap.size();
20830 return NULL;
20831 }
20832
20833 return ffcmap[index].output.c_str();
20834 }
20835
20836 const char *assigngloballist(int32_t index, int32_t *list_size)
20837 {
20838 if(index<0)
20839 {
20840 *list_size = (int32_t)globalmap.size();
20841 return NULL;
20842 }
20843
20844 return globalmap[index].output.c_str();
20845 }
20846
20847 const char *assigncombolist(int32_t index, int32_t *list_size)
20848 {
20849 if(index<0)
20850 {
20851 *list_size = (int32_t)comboscriptmap.size();
20852 return NULL;
20853 }
20854
20855 return comboscriptmap[index].output.c_str();
20856 }
20857
20858 const char *assigngenericlist(int32_t index, int32_t *list_size)
20859 {
20860 if(index<0)
20861 {
20862 *list_size = ((int32_t)genericmap.size());
20863 return NULL;
20864 }
20865
20866 return genericmap[index].output.c_str();
20867 }
20868
20869 const char *assignsubscreenlist(int32_t index, int32_t *list_size)
20870 {
20871 if(index<0)
20872 {
20873 *list_size = ((int32_t)subscreenmap.size());
20874 return NULL;
20875 }
20876
20877 return subscreenmap[index].output.c_str();
20878 }
20879
20880 const char *assignitemlist(int32_t index, int32_t *list_size)
20881 {
20882 if(index<0)
20883 {
20884 *list_size = (int32_t)itemmap.size();
20885 return NULL;
20886 }
20887
20888 return itemmap[index].output.c_str();
20889 }
20890 const char *assignnpclist(int32_t index, int32_t *list_size)
20891 {
20892 if(index<0)
20893 {
20894 *list_size = (int32_t)npcmap.size();
20895 return NULL;
20896 }
20897
20898 return npcmap[index].output.c_str();
20899 }
20900
20901 const char *assignlweaponlist(int32_t index, int32_t *list_size)
20902 {
20903 if(index<0)
20904 {
20905 *list_size = (int32_t)lwpnmap.size();
20906 return NULL;
20907 }
20908
20909 return lwpnmap[index].output.c_str();
20910 }
20911
20912 const char *assigneweaponlist(int32_t index, int32_t *list_size)
20913 {
20914 if(index<0)
20915 {
20916 *list_size = (int32_t)ewpnmap.size();
20917 return NULL;
20918 }
20919
20920 return ewpnmap[index].output.c_str();
20921 }
20922
20923 const char *assignplayerlist(int32_t index, int32_t *list_size)
20924 {
20925 if(index<0)
20926 {
20927 *list_size = (int32_t)playermap.size();
20928 return NULL;
20929 }
20930
20931 return playermap[index].output.c_str();
20932 }
20933
20934 const char *assigndmaplist(int32_t index, int32_t *list_size)
20935 {
20936 if(index<0)
20937 {
20938 *list_size = (int32_t)dmapmap.size();
20939 return NULL;
20940 }
20941
20942 return dmapmap[index].output.c_str();
20943 }
20944
20945 const char *assignscreenlist(int32_t index, int32_t *list_size)
20946 {
20947 if(index<0)
20948 {
20949 *list_size = (int32_t)screenmap.size();
20950 return NULL;
20951 }
20952
20953 return screenmap[index].output.c_str();
20954 }
20955
20956 const char *assignitemspritelist(int32_t index, int32_t *list_size)
20957 {
20958 if(index<0)
20959 {
20960 *list_size = (int32_t)itemspritemap.size();
20961 return NULL;
20962 }
20963
20964 return itemspritemap[index].output.c_str();
20965 }
20966
20967 const char *assignffcscriptlist(int32_t index, int32_t *list_size)
20968 {
20969 if(index<0)
20970 {
20971 *list_size = (int32_t)asffcscripts.size();
20972 return NULL;
20973 }
20974
20975 return asffcscripts[index].c_str();
20976 }
20977
20978 const char *assignglobalscriptlist(int32_t index, int32_t *list_size)
20979 {
20980 if(index<0)
20981 {
20982 *list_size = (int32_t)asglobalscripts.size();
20983 return NULL;
20984 }
20985
20986 return asglobalscripts[index].c_str();
20987 }
20988
20989 const char *assignitemscriptlist(int32_t index, int32_t *list_size)
20990 {
20991 if(index<0)
20992 {
20993 *list_size = (int32_t)asitemscripts.size();
20994 return NULL;
20995 }
20996
20997 return asitemscripts[index].c_str();
20998 }
20999
21000 const char *assignnpcscriptlist(int32_t index, int32_t *list_size)
21001 {
21002 if(index<0)
21003 {
21004 *list_size = (int32_t)asnpcscripts.size();
21005 return NULL;
21006 }
21007
21008 return asnpcscripts[index].c_str();
21009 }
21010
21011 const char *assignlweaponscriptlist(int32_t index, int32_t *list_size)
21012 {
21013 if(index<0)
21014 {
21015 *list_size = (int32_t)aslweaponscripts.size();
21016 return NULL;
21017 }
21018
21019 return aslweaponscripts[index].c_str();
21020 }
21021
21022 const char *assigneweaponscriptlist(int32_t index, int32_t *list_size)
21023 {
21024 if(index<0)
21025 {
21026 *list_size = (int32_t)aseweaponscripts.size();
21027 return NULL;
21028 }
21029
21030 return aseweaponscripts[index].c_str();
21031 }
21032
21033 const char *assignplayerscriptlist(int32_t index, int32_t *list_size)
21034 {
21035 if(index<0)
21036 {
21037 *list_size = (int32_t)asplayerscripts.size();
21038 return NULL;
21039 }
21040
21041 return asplayerscripts[index].c_str();
21042 }
21043
21044 const char *assigndmapscriptlist(int32_t index, int32_t *list_size)
21045 {
21046 if(index<0)
21047 {
21048 *list_size = (int32_t)asdmapscripts.size();
21049 return NULL;
21050 }
21051
21052 return asdmapscripts[index].c_str();
21053 }
21054
21055 const char *assignscreenscriptlist(int32_t index, int32_t *list_size)
21056 {
21057 if(index<0)
21058 {
21059 *list_size = (int32_t)asscreenscripts.size();
21060 return NULL;
21061 }
21062
21063 return asscreenscripts[index].c_str();
21064 }
21065
21066 const char *assignitemspritescriptlist(int32_t index, int32_t *list_size)
21067 {
21068 if(index<0)
21069 {
21070 *list_size = (int32_t)asitemspritescripts.size();
21071 return NULL;
21072 }
21073
21074 return asitemspritescripts[index].c_str();
21075 }
21076
21077 const char *assigncomboscriptlist(int32_t index, int32_t *list_size)
21078 {
21079 if(index<0)
21080 {
21081 *list_size = (int32_t)ascomboscripts.size();
21082 return NULL;
21083 }
21084
21085 return ascomboscripts[index].c_str();
21086 }
21087
21088 const char *assigngenericscriptlist(int32_t index, int32_t *list_size)
21089 {
21090 if(index<0)
21091 {
21092 *list_size = (int32_t)asgenericscripts.size();
21093 return NULL;
21094 }
21095
21096 return asgenericscripts[index].c_str();
21097 }
21098
21099 const char *assignsubscreenscriptlist(int32_t index, int32_t *list_size)
21100 {
21101 if(index<0)
21102 {
21103 *list_size = (int32_t)assubscreenscripts.size();
21104 return NULL;
21105 }
21106
21107 return assubscreenscripts[index].c_str();
21108 }
21109
21110 8 static ListData assignffc_list(assignffclist, &font);
21111 8 static ListData assignffcscript_list(assignffcscriptlist, &font);
21112 8 static ListData assignglobal_list(assigngloballist, &font);
21113 8 static ListData assignglobalscript_list(assignglobalscriptlist, &font);
21114 8 static ListData assignitem_list(assignitemlist, &font);
21115 8 static ListData assignitemscript_list(assignitemscriptlist, &font);
21116 8 static ListData assignnpc_list(assignnpclist, &font);
21117 8 static ListData assignnpcscript_list(assignnpcscriptlist, &font);
21118 8 static ListData assignlweapon_list(assignlweaponlist, &font);
21119 8 static ListData assignlweaponscript_list(assignlweaponscriptlist, &font);
21120 8 static ListData assigneweapon_list(assigneweaponlist, &font);
21121 8 static ListData assigneweaponscript_list(assigneweaponscriptlist, &font);
21122
21123 8 static ListData assignplayer_list(assignplayerlist, &font);
21124 8 static ListData assignplayerscript_list(assignplayerscriptlist, &font);
21125
21126 8 static ListData assigndmap_list(assigndmaplist, &font);
21127 8 static ListData assigndmapscript_list(assigndmapscriptlist, &font);
21128
21129 8 static ListData assignscreen_list(assignscreenlist, &font);
21130 8 static ListData assignscreenscript_list(assignscreenscriptlist, &font);
21131
21132 8 static ListData assignitemsprite_list(assignitemspritelist, &font);
21133 8 static ListData assignitemspritescript_list(assignitemspritescriptlist, &font);
21134
21135 8 static ListData assigncombo_list(assigncombolist, &font);
21136 8 static ListData assigncomboscript_list(assigncomboscriptlist, &font);
21137
21138 8 static ListData assigngeneric_list(assigngenericlist, &font);
21139 8 static ListData assigngenericscript_list(assigngenericscriptlist, &font);
21140
21141 8 static ListData assignsubscreen_list(assignsubscreenlist, &font);
21142 8 static ListData assignsubscreenscript_list(assignsubscreenscriptlist, &font);
21143
21144 static DIALOG assignscript_dlg[] =
21145 {
21146 // x y w h fg bg key flags d1 d2 dp
21147 8 { jwin_win_proc, 0, 0, 330, 236, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Assign Compiled Script", NULL, NULL },
21148 8 { jwin_tab_proc, 6, 25, 330-12, 130, 0, 0, 0, 0, 0, 0, assignscript_tabs, NULL, (void*)assignscript_dlg },
21149 8 { jwin_button_proc, 251, 207, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
21150 8 { jwin_button_proc, 182, 207, 61, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
21151 8 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignffc_list, NULL, NULL },
21152 8 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignffcscript_list, NULL, NULL },
21153 //6
21154 8 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
21155 8 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignglobal_list, NULL, NULL },
21156 8 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignglobalscript_list, NULL, NULL },
21157 //9
21158 8 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
21159 8 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignitem_list, NULL, NULL },
21160 8 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignitemscript_list, NULL, NULL },
21161 //12
21162 8 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
21163 //13
21164 8 { jwin_check_proc, 22, 211, 90, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Output ZASM code to allegro.log", NULL, NULL },
21165 8 { jwin_text_proc, 22, 178, 90, 24, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
21166 8 { d_dummy_proc, 0, 0, 0, 0, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
21167 //16
21168 8 { d_dummy_proc, 0, 0, 0, 0, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
21169 8 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
21170 //npc scripts
21171 8 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignnpc_list, NULL, NULL },
21172 8 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignnpcscript_list, NULL, NULL },
21173 //20
21174 8 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
21175 //21
21176 8 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignlweapon_list, NULL, NULL },
21177 8 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignlweaponscript_list, NULL, NULL },
21178 //23
21179 8 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
21180 //24
21181 8 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigneweapon_list, NULL, NULL },
21182 8 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigneweaponscript_list, NULL, NULL },
21183 //26
21184 8 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
21185 //27
21186 8 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignplayer_list, NULL, NULL },
21187 8 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignplayerscript_list, NULL, NULL },
21188 //29
21189 8 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
21190 //30
21191 8 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignscreen_list, NULL, NULL },
21192 8 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignscreenscript_list, NULL, NULL },
21193 //32
21194 8 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
21195 //33
21196 8 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigndmap_list, NULL, NULL },
21197 8 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigndmapscript_list, NULL, NULL },
21198 //35
21199 8 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
21200 //36
21201 8 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignitemsprite_list, NULL, NULL },
21202 8 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignitemspritescript_list, NULL, NULL },
21203 //38
21204 8 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
21205
21206 //39
21207 8 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigncombo_list, NULL, NULL },
21208 8 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigncomboscript_list, NULL, NULL },
21209 //41
21210 8 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
21211 8 { jwin_button_proc, 78-24, 158, 48, 16, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Script Info", NULL, NULL },
21212 8 { jwin_button_proc, 174+78-24, 158, 48, 16, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Script Info", NULL, NULL },
21213 8 { jwin_button_proc, 87+78-24, 158, 48, 16, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Clear", NULL, NULL },
21214 //45
21215 8 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigngeneric_list, NULL, NULL },
21216 8 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigngenericscript_list, NULL, NULL },
21217 //47
21218 8 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
21219 //48
21220 8 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignsubscreen_list, NULL, NULL },
21221 8 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignsubscreenscript_list, NULL, NULL },
21222 //50
21223 8 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
21224 8 { jwin_check_proc, 22, 221, 90, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "...And output ZASM comments", NULL, NULL },
21225
21226 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
21227
21228 };
21229
21230 int32_t txtout(BITMAP* dest, const char* txt, int32_t x, int32_t y, bool disabled)
21231 {
21232 if(disabled)
21233 {
21234 gui_textout_ln(dest, font, (uint8_t*)txt, x+1, y+1, scheme[jcLIGHT], scheme[jcBOX], 0);
21235 return gui_textout_ln(dest, font, (uint8_t*)txt, x, y, scheme[jcMEDDARK], -1, 0);
21236 }
21237 else
21238 {
21239 return gui_textout_ln(dest, font, (uint8_t*)txt, x, y, scheme[jcBOXFG], scheme[jcBOX], 0);
21240 }
21241 }
21242
21243 int32_t jwin_zmeta_proc(int32_t msg, DIALOG *d, int32_t )
21244 {
21245 int32_t ret = D_O_K;
21246 ASSERT(d);
21247
21248 BITMAP* target = (msg==MSG_START ? NULL : screen);
21249 switch(msg)
21250 {
21251 case MSG_START:
21252 case MSG_DRAW:
21253 {
21254 FONT *oldfont = font;
21255
21256 if(d->dp2)
21257 {
21258 font = (FONT*)d->dp2;
21259 }
21260
21261 bool disabled = (d->flags & D_DISABLED) != 0;
21262 if(d->dp)
21263 {
21264 zasm_meta const& meta = *((zasm_meta*)d->dp);
21265 int32_t ind = -1;
21266 d->w = 0;
21267 if(!meta.valid())
21268 {
21269 d->w = txtout(target, "Invalid ZASM metadata found!", d->x, d->y, disabled);
21270 ++ind;
21271 }
21272
21273 int32_t t_w = 0;
21274 char buf[1024];
21275 memset(buf, 0, sizeof(buf));
21276 sprintf(buf, "ZASM Version: %d", meta.zasm_v);
21277 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
21278 d->w = zc_max(d->w, t_w);
21279 memset(buf, 0, sizeof(buf));
21280 sprintf(buf, "Metadata Version: %d", meta.meta_v);
21281 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
21282 d->w = zc_max(d->w, t_w);
21283 memset(buf, 0, sizeof(buf));
21284 sprintf(buf, "FFScript Version: %d", meta.ffscript_v);
21285 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
21286 d->w = zc_max(d->w, t_w);
21287 memset(buf, 0, sizeof(buf));
21288 sprintf(buf, "Script Name: %s", meta.script_name.c_str());
21289 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
21290 d->w = zc_max(d->w, t_w);
21291 memset(buf, 0, sizeof(buf));
21292 sprintf(buf, "Author: %s", meta.author.c_str());
21293 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
21294 d->w = zc_max(d->w, t_w);
21295 memset(buf, 0, sizeof(buf));
21296 sprintf(buf, "Script Type: %s", get_script_name(meta.script_type).c_str());
21297 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
21298 d->w = zc_max(d->w, t_w);
21299 for(auto q = 0; q < 4; ++q)
21300 {
21301 if(!meta.attributes[q].size())
21302 continue;
21303 memset(buf, 0, sizeof(buf));
21304 sprintf(buf, "Attributes[%d]: %s", q, meta.attributes[q].c_str());
21305 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
21306 d->w = zc_max(d->w, t_w);
21307 }
21308 for(auto q = 0; q < 8; ++q)
21309 {
21310 if(!meta.attribytes[q].size())
21311 continue;
21312 memset(buf, 0, sizeof(buf));
21313 sprintf(buf, "Attribytes[%d]: %s", q, meta.attribytes[q].c_str());
21314 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
21315 d->w = zc_max(d->w, t_w);
21316 }
21317 for(auto q = 0; q < 8; ++q)
21318 {
21319 if(!meta.attrishorts[q].size())
21320 continue;
21321 memset(buf, 0, sizeof(buf));
21322 sprintf(buf, "Attrishorts[%d]: %s", q, meta.attrishorts[q].c_str());
21323 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
21324 d->w = zc_max(d->w, t_w);
21325 }
21326 bool indentrun = false;
21327 int32_t run_indent = txtout(NULL, "void run(", 0, 0, false);
21328 std::ostringstream oss;
21329 oss << "void run(";
21330 for(int32_t q = 0; q < 8; ++q)
21331 {
21332 if(!meta.run_idens[q].size() || meta.run_types[q] == ZMETA_NULL_TYPE) continue;
21333 if(q > 0)
21334 oss << ", ";
21335 string type_name = ZScript::getDataTypeName(meta.run_types[q]);
21336 lowerstr(type_name); //all lowercase for this output
21337 if(oss.str().size() > unsigned(indentrun ? 41 : 50))
21338 {
21339 memset(buf, 0, sizeof(buf));
21340 sprintf(buf, "%s", oss.str().c_str());
21341 t_w = txtout(target, buf, d->x + (indentrun ? run_indent : 0), d->y + ((++ind)*(text_height(font) + 3)), disabled) + (indentrun ? run_indent : 0);
21342 d->w = zc_max(d->w, t_w);
21343 oss.str("");
21344 indentrun = true;
21345 }
21346 oss << type_name.c_str() << " " << meta.run_idens[q];
21347 }
21348 oss << ");";
21349 memset(buf, 0, sizeof(buf));
21350 sprintf(buf, "%s", oss.str().c_str());
21351 t_w = txtout(target, buf, d->x + (indentrun ? run_indent : 0), d->y + ((++ind)*(text_height(font) + 3)), disabled) + (indentrun ? run_indent : 0);
21352 d->w = zc_max(d->w, t_w);
21353 memset(buf, 0, sizeof(buf));
21354 sprintf(buf, "Compiler Version: %d.%d.%d.%d", meta.compiler_v1, meta.compiler_v2, meta.compiler_v3, meta.compiler_v4);
21355 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
21356 d->w = zc_max(d->w, t_w);
21357 memset(buf, 0, sizeof(buf));
21358 sprintf(buf, "Parser-generated: %s", (meta.flags & ZMETA_AUTOGEN)!=0 ? "TRUE" : "FALSE");
21359 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
21360 d->w = zc_max(d->w, t_w);
21361 d->h = (++ind) * (text_height(font) + 3) -3;
21362 }
21363 else
21364 {
21365 d->w = txtout(target, "No ZASM metadata found!", d->x, d->y, disabled);
21366 d->h = text_height(font);
21367 }
21368
21369 if(d->dp3) //function trigger
21370 {
21371 typedef void (*funcType)(void);
21372 funcType func=reinterpret_cast<funcType>(d->dp3);
21373 func();
21374 }
21375
21376 font = oldfont;
21377 break;
21378 }
21379 }
21380
21381 return ret;
21382 }
21383
21384 void resize_scriptinfo_dlg();
21385
21386 static DIALOG scriptinfo_dlg[] =
21387 {
21388 // x y w h fg bg key flags d1 d2 dp
21389 { jwin_win_proc, 0, 0, 200, 150, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Script Metadata", NULL, NULL },
21390 { d_dummy_proc, 6, 25, 330-12, 130, 0, 0, 0, 0, 0, 0, assignscript_tabs, NULL, NULL },
21391 { jwin_button_proc, 70, 120, 60, 20, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "Done", NULL, NULL },
21392 { jwin_zmeta_proc, 50, 30, 100, 100, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, (void*)resize_scriptinfo_dlg },
21393
21394 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
21395 };
21396
21397 void resize_scriptinfo_dlg()
21398 {
21399 DIALOG *meta_proc = &scriptinfo_dlg[3], *window = &scriptinfo_dlg[0], *ok_button = &scriptinfo_dlg[2];
21400 int32_t bmargin = 15, hmargins = 30;
21401 jwin_ulalign_dialog(scriptinfo_dlg);
21402 window->w = hmargins*2 + meta_proc->w;
21403 meta_proc->x = hmargins;
21404 window->h = meta_proc->y + meta_proc->h + ok_button->h + bmargin*2;
21405 ok_button->x = (window->w/2)-(ok_button->w/2);
21406 ok_button->y = meta_proc->y + meta_proc->h + bmargin;
21407 jwin_center_dialog(scriptinfo_dlg);
21408 }
21409
21410 void showScriptInfo(zasm_meta const* meta)
21411 {
21412 scriptinfo_dlg[3].dp = (void*)meta;
21413 scriptinfo_dlg[0].dp2 = get_zc_font(font_lfont);
21414 large_dialog(scriptinfo_dlg);
21415 jwin_zmeta_proc(MSG_START,&scriptinfo_dlg[3],0); //Calculate size before calling dialog
21416 jwin_center_dialog(scriptinfo_dlg);
21417 do_zqdialog(scriptinfo_dlg,2);
21418 }
21419
21420 void write_includepaths();
21421 void call_compile_settings();
21422 int32_t onZScriptCompilerSettings()
21423 {
21424 call_compile_settings();
21425 return D_O_K;
21426 }
21427
21428 void doEditZScript()
21429 {
21430 if(do_box_edit(zScript, "ZScript Buffer", false, false))
21431 saved=false;
21432 }
21433
21434 std::string qst_cfg_header_from_path(std::string path);
21435 extern char *filepath;
21436 string get_box_cfg_hdr(int num)
21437 {
21438 if(num)
21439 return "misc";
21440 return qst_cfg_header_from_path(filepath);
21441 }
21442
21443 //{ Start type-specific import dlgs
21444 8 static ListData ffscript_sel_dlg_list(ffscriptlist2, &font);
21445 8 static ListData itemscript_sel_dlg_list(itemscriptlist2, &font);
21446 8 static ListData comboscript_sel_dlg_list(comboscriptlist2, &font);
21447 8 static ListData gscript_sel_dlg_list(gscriptlist2, &font);
21448 static char npcscript_str_buf2[32];
21449 const char *npcscriptlist2(int32_t index, int32_t *list_size)
21450 {
21451 if(index>=0)
21452 {
21453 char buf[20];
21454 bound(index,0,254);
21455
21456 if(npcmap[index].scriptname=="")
21457 strcpy(buf, "<none>");
21458 else
21459 {
21460 strncpy(buf, npcmap[index].scriptname.c_str(), 19);
21461 buf[19]='\0';
21462 }
21463
21464 sprintf(npcscript_str_buf2,"%d: %s",index+1, buf);
21465 return npcscript_str_buf2;
21466 }
21467
21468 *list_size=(NUMSCRIPTGUYS-1);
21469 return NULL;
21470 }
21471 8 static ListData npcscript_sel_dlg_list(npcscriptlist2, &font);
21472 static char lweaponscript_str_buf2[32];
21473 const char *lweaponscriptlist2(int32_t index, int32_t *list_size)
21474 {
21475 if(index>=0)
21476 {
21477 char buf[20];
21478 bound(index,0,254);
21479
21480 if(lwpnmap[index].scriptname=="")
21481 strcpy(buf, "<none>");
21482 else
21483 {
21484 strncpy(buf, lwpnmap[index].scriptname.c_str(), 19);
21485 buf[19]='\0';
21486 }
21487
21488 sprintf(lweaponscript_str_buf2,"%d: %s",index+1, buf);
21489 return lweaponscript_str_buf2;
21490 }
21491
21492 *list_size=(NUMSCRIPTWEAPONS-1);
21493 return NULL;
21494 }
21495 8 static ListData lweaponscript_sel_dlg_list(lweaponscriptlist2, &font);
21496 static char eweaponscript_str_buf2[32];
21497 const char *eweaponscriptlist2(int32_t index, int32_t *list_size)
21498 {
21499 if(index>=0)
21500 {
21501 char buf[20];
21502 bound(index,0,254);
21503
21504 if(ewpnmap[index].scriptname=="")
21505 strcpy(buf, "<none>");
21506 else
21507 {
21508 strncpy(buf, ewpnmap[index].scriptname.c_str(), 19);
21509 buf[19]='\0';
21510 }
21511
21512 sprintf(eweaponscript_str_buf2,"%d: %s",index+1, buf);
21513 return eweaponscript_str_buf2;
21514 }
21515
21516 *list_size=(NUMSCRIPTWEAPONS-1);
21517 return NULL;
21518 }
21519 8 static ListData eweaponscript_sel_dlg_list(eweaponscriptlist2, &font);
21520 static char playerscript_str_buf2[32];
21521 const char *playerscriptlist2(int32_t index, int32_t *list_size)
21522 {
21523 if(index>=0)
21524 {
21525 char buf[20];
21526 bound(index,0,3);
21527
21528 if(playermap[index].scriptname=="")
21529 strcpy(buf, "<none>");
21530 else
21531 {
21532 strncpy(buf, playermap[index].scriptname.c_str(), 19);
21533 buf[19]='\0';
21534 }
21535
21536 if(index==0)
21537 sprintf(playerscript_str_buf2,"Init: %s", buf);
21538
21539 if(index==1)
21540 sprintf(playerscript_str_buf2,"Active: %s", buf);
21541
21542 if(index==2)
21543 sprintf(playerscript_str_buf2,"Death: %s", buf);
21544
21545
21546 //sprintf(playerscript_str_buf2,"%d: %s",index+1, buf);
21547 return playerscript_str_buf2;
21548 }
21549
21550 *list_size=(NUMSCRIPTPLAYER-1);
21551 return NULL;
21552 }
21553 static char itemspritescript_str_buf2[32];
21554 const char *itemspritescriptlist2(int32_t index, int32_t *list_size)
21555 {
21556 if(index>=0)
21557 {
21558 char buf[20];
21559 bound(index,0,254);
21560
21561 if(itemspritemap[index].scriptname=="")
21562 strcpy(buf, "<none>");
21563 else
21564 {
21565 strncpy(buf, itemspritemap[index].scriptname.c_str(), 19);
21566 buf[19]='\0';
21567 }
21568
21569 sprintf(itemspritescript_str_buf2,"%d: %s",index+1, buf);
21570 return itemspritescript_str_buf2;
21571 }
21572
21573 *list_size=(NUMSCRIPTSITEMSPRITE-1);
21574 return NULL;
21575 }
21576 8 static ListData playerscript_sel_dlg_list(playerscriptlist2, &font);
21577 static char dmapscript_str_buf2[32];
21578 const char *dmapscriptlist2(int32_t index, int32_t *list_size)
21579 {
21580 if(index>=0)
21581 {
21582 char buf[20];
21583 bound(index,0,254);
21584
21585 if(dmapmap[index].scriptname=="")
21586 strcpy(buf, "<none>");
21587 else
21588 {
21589 strncpy(buf, dmapmap[index].scriptname.c_str(), 19);
21590 buf[19]='\0';
21591 }
21592
21593 sprintf(dmapscript_str_buf2,"%d: %s",index+1, buf);
21594 return dmapscript_str_buf2;
21595 }
21596
21597 *list_size=(NUMSCRIPTSDMAP-1);
21598 return NULL;
21599 }
21600 8 static ListData dmapscript_sel_dlg_list(dmapscriptlist2, &font);
21601 8 static ListData itemspritescript_sel_dlg_list(itemspritescriptlist2, &font);
21602 static char screenscript_str_buf2[32];
21603 const char *screenscriptlist2(int32_t index, int32_t *list_size)
21604 {
21605 if(index>=0)
21606 {
21607 char buf[20];
21608 bound(index,0,254);
21609
21610 if(screenmap[index].scriptname=="")
21611 strcpy(buf, "<none>");
21612 else
21613 {
21614 strncpy(buf, screenmap[index].scriptname.c_str(), 19);
21615 buf[19]='\0';
21616 }
21617
21618 sprintf(screenscript_str_buf2,"%d: %s",index+1, buf);
21619 return screenscript_str_buf2;
21620 }
21621
21622 *list_size=(NUMSCRIPTSCREEN-1);
21623 return NULL;
21624 }
21625 8 static ListData screenscript_sel_dlg_list(screenscriptlist2, &font);
21626 //} End type-specific import dlgs
21627
21628 3 void clear_map_states()
21629 {
21630
2/2
✓ Branch 0 taken 1533 times.
✓ Branch 1 taken 3 times.
1536 for(map<int32_t, script_slot_data>::iterator it = ffcmap.begin();
21631 1536 it != ffcmap.end(); ++it)
21632 {
21633 1533 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
21634 1533 }
21635
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 3 times.
27 for(map<int32_t, script_slot_data>::iterator it = globalmap.begin();
21636 27 it != globalmap.end(); ++it)
21637 {
21638 24 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
21639 24 }
21640
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 for(map<int32_t, script_slot_data>::iterator it = itemmap.begin();
21641 768 it != itemmap.end(); ++it)
21642 {
21643 765 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
21644 765 }
21645
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 for(map<int32_t, script_slot_data>::iterator it = npcmap.begin();
21646 768 it != npcmap.end(); ++it)
21647 {
21648 765 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
21649 765 }
21650
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 for(map<int32_t, script_slot_data>::iterator it = ewpnmap.begin();
21651 768 it != ewpnmap.end(); ++it)
21652 {
21653 765 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
21654 765 }
21655
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 for(map<int32_t, script_slot_data>::iterator it = lwpnmap.begin();
21656 768 it != lwpnmap.end(); ++it)
21657 {
21658 765 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
21659 765 }
21660
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(map<int32_t, script_slot_data>::iterator it = playermap.begin();
21661 15 it != playermap.end(); ++it)
21662 {
21663 12 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
21664 12 }
21665
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 for(map<int32_t, script_slot_data>::iterator it = dmapmap.begin();
21666 768 it != dmapmap.end(); ++it)
21667 {
21668 765 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
21669 765 }
21670
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 for(map<int32_t, script_slot_data>::iterator it = screenmap.begin();
21671 768 it != screenmap.end(); ++it)
21672 {
21673 765 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
21674 765 }
21675
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 for(map<int32_t, script_slot_data>::iterator it = itemspritemap.begin();
21676 768 it != itemspritemap.end(); ++it)
21677 {
21678 765 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
21679 765 }
21680
2/2
✓ Branch 0 taken 1533 times.
✓ Branch 1 taken 3 times.
1536 for(map<int32_t, script_slot_data>::iterator it = comboscriptmap.begin();
21681 1536 it != comboscriptmap.end(); ++it)
21682 {
21683 1533 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
21684 1533 }
21685 3 }
21686
21687 3 void clearAssignSlotDlg()
21688 {
21689 3 assignscript_dlg[0].dp2 = get_zc_font(font_lfont);
21690 3 assignscript_dlg[4].d1 = -1;
21691 3 assignscript_dlg[5].d1 = -1;
21692 3 assignscript_dlg[7].d1 = -1;
21693 3 assignscript_dlg[8].d1 = -1;
21694 3 assignscript_dlg[10].d1 = -1;
21695 3 assignscript_dlg[11].d1 = -1;
21696 3 assignscript_dlg[13].flags = 0;
21697 3 }
21698
21699 int32_t onSlotAssign()
21700 {
21701 clearAssignSlotDlg();
21702 //Clear right-hand side of names
21703 asffcscripts.clear();
21704 asffcscripts.push_back("<none>");
21705 asglobalscripts.clear();
21706 asglobalscripts.push_back("<none>");
21707 asitemscripts.clear();
21708 asitemscripts.push_back("<none>");
21709 asnpcscripts.clear();
21710 asnpcscripts.push_back("<none>");
21711 aseweaponscripts.clear();
21712 aseweaponscripts.push_back("<none>");
21713 aslweaponscripts.clear();
21714 aslweaponscripts.push_back("<none>");
21715 asplayerscripts.clear();
21716 asplayerscripts.push_back("<none>");
21717 asdmapscripts.clear();
21718 asdmapscripts.push_back("<none>");
21719 asscreenscripts.clear();
21720 asscreenscripts.push_back("<none>");
21721 asitemspritescripts.clear();
21722 asitemspritescripts.push_back("<none>");
21723
21724 ascomboscripts.clear();
21725 ascomboscripts.push_back("<none>");
21726 asgenericscripts.clear();
21727 asgenericscripts.push_back("<none>");
21728 assubscreenscripts.clear();
21729 assubscreenscripts.push_back("<none>");
21730 //Declare new script vector
21731 map<string, disassembled_script_data> scripts;
21732
21733 do_script_disassembly(scripts, false);
21734
21735 do_slots(scripts, false);
21736 return D_O_K;
21737 }
21738
21739 void inc_script_name(string& name)
21740 {
21741 size_t pos = name.find_last_not_of("0123456789");
21742 pos = name.find_first_of("0123456789",pos);
21743 std::ostringstream oss;
21744 if(pos == string::npos)
21745 {
21746 oss << name << 2;
21747 }
21748 else
21749 {
21750 int32_t val = atoi(name.substr(pos).c_str());
21751 oss << name.substr(0,pos) << val+1;
21752 }
21753 name = oss.str();
21754 }
21755
21756 3 void do_script_disassembly(map<string, disassembled_script_data>& scripts, bool fromCompile)
21757 {
21758 3 clearAssignSlotDlg();
21759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 bool skipDisassembled = fromCompile && try_recovering_missing_scripts == 0;
21760
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 3 times.
27 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
21761 {
21762
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(scripts.find(globalmap[i].scriptname) != scripts.end())
21763 {
21764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(scripts[globalmap[i].scriptname].first.script_type != ScriptType::Global)
21765 {
21766 while(scripts.find(globalmap[i].scriptname) != scripts.end())
21767 inc_script_name(globalmap[i].scriptname);
21768 }
21769 6 else continue;
21770 }
21771
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 switch(i)
21772 {
21773 case GLOBAL_SCRIPT_INIT:
21774 {
21775 break;
21776 }
21777 default:
21778
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!globalmap[i].isEmpty())
21779 {
21780 globalmap[i].format = SCRIPT_FORMAT_INVALID;
21781 }
21782 18 }
21783 18 }
21784
2/2
✓ Branch 0 taken 1533 times.
✓ Branch 1 taken 3 times.
1536 for(int32_t i = 0; i < NUMSCRIPTFFC-1; ++i)
21785 {
21786
2/2
✓ Branch 0 taken 1470 times.
✓ Branch 1 taken 63 times.
1533 if(scripts.find(ffcmap[i].scriptname) != scripts.end())
21787 {
21788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(scripts[ffcmap[i].scriptname].first.script_type != ScriptType::FFC)
21789 {
21790 while(scripts.find(ffcmap[i].scriptname) != scripts.end())
21791 inc_script_name(ffcmap[i].scriptname);
21792 }
21793 63 else continue;
21794 }
21795
2/2
✓ Branch 0 taken 1469 times.
✓ Branch 1 taken 1 times.
1470 if(!ffcmap[i].isEmpty())
21796 {
21797 1 ffcmap[i].format = SCRIPT_FORMAT_INVALID;
21798 1 }
21799 1470 }
21800
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 for(int32_t i = 0; i < NUMSCRIPTITEM-1; ++i)
21801 {
21802
2/2
✓ Branch 0 taken 754 times.
✓ Branch 1 taken 11 times.
765 if(scripts.find(itemmap[i].scriptname) != scripts.end())
21803 {
21804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(scripts[itemmap[i].scriptname].first.script_type != ScriptType::Item)
21805 {
21806 while(scripts.find(itemmap[i].scriptname) != scripts.end())
21807 inc_script_name(itemmap[i].scriptname);
21808 }
21809 11 else continue;
21810 }
21811
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!itemmap[i].isEmpty())
21812 {
21813 itemmap[i].format = SCRIPT_FORMAT_INVALID;
21814 }
21815 754 }
21816
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 for(int32_t i = 0; i < NUMSCRIPTGUYS-1; ++i)
21817 {
21818
1/2
✓ Branch 0 taken 765 times.
✗ Branch 1 not taken.
765 if(scripts.find(npcmap[i].scriptname) != scripts.end())
21819 {
21820 if(scripts[npcmap[i].scriptname].first.script_type != ScriptType::NPC)
21821 {
21822 while(scripts.find(npcmap[i].scriptname) != scripts.end())
21823 inc_script_name(npcmap[i].scriptname);
21824 }
21825 else continue;
21826 }
21827
1/2
✓ Branch 0 taken 765 times.
✗ Branch 1 not taken.
765 if(!npcmap[i].isEmpty())
21828 {
21829 npcmap[i].format = SCRIPT_FORMAT_INVALID;
21830 }
21831 765 }
21832
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 for(int32_t i = 0; i < NUMSCRIPTWEAPONS-1; ++i)
21833 {
21834
1/2
✓ Branch 0 taken 765 times.
✗ Branch 1 not taken.
765 if(scripts.find(lwpnmap[i].scriptname) != scripts.end())
21835 {
21836 if(scripts[lwpnmap[i].scriptname].first.script_type != ScriptType::Lwpn)
21837 {
21838 while(scripts.find(lwpnmap[i].scriptname) != scripts.end())
21839 inc_script_name(lwpnmap[i].scriptname);
21840 }
21841 else continue;
21842 }
21843
1/2
✓ Branch 0 taken 765 times.
✗ Branch 1 not taken.
765 if(!lwpnmap[i].isEmpty())
21844 {
21845 lwpnmap[i].format = SCRIPT_FORMAT_INVALID;
21846 }
21847 765 }
21848
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 for(int32_t i = 0; i < NUMSCRIPTWEAPONS-1; ++i)
21849 {
21850
1/2
✓ Branch 0 taken 765 times.
✗ Branch 1 not taken.
765 if(scripts.find(ewpnmap[i].scriptname) != scripts.end())
21851 {
21852 if(scripts[ewpnmap[i].scriptname].first.script_type != ScriptType::Ewpn)
21853 {
21854 while(scripts.find(ewpnmap[i].scriptname) != scripts.end())
21855 inc_script_name(ewpnmap[i].scriptname);
21856 }
21857 else continue;
21858 }
21859
1/2
✓ Branch 0 taken 765 times.
✗ Branch 1 not taken.
765 if(!ewpnmap[i].isEmpty())
21860 {
21861 ewpnmap[i].format = SCRIPT_FORMAT_INVALID;
21862 }
21863 765 }
21864
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t i = 0; i < NUMSCRIPTPLAYER-1; ++i)
21865 {
21866
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(scripts.find(playermap[i].scriptname) != scripts.end())
21867 {
21868 if(scripts[playermap[i].scriptname].first.script_type != ScriptType::Player)
21869 {
21870 while(scripts.find(playermap[i].scriptname) != scripts.end())
21871 inc_script_name(playermap[i].scriptname);
21872 }
21873 else continue;
21874 }
21875
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!playermap[i].isEmpty())
21876 {
21877 playermap[i].format = SCRIPT_FORMAT_INVALID;
21878 }
21879 12 }
21880
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 for(int32_t i = 0; i < NUMSCRIPTSDMAP-1; ++i)
21881 {
21882
2/2
✓ Branch 0 taken 763 times.
✓ Branch 1 taken 2 times.
765 if(scripts.find(dmapmap[i].scriptname) != scripts.end())
21883 {
21884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(scripts[dmapmap[i].scriptname].first.script_type != ScriptType::DMap)
21885 {
21886 while(scripts.find(dmapmap[i].scriptname) != scripts.end())
21887 inc_script_name(dmapmap[i].scriptname);
21888 }
21889 2 else continue;
21890 }
21891
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if(!dmapmap[i].isEmpty())
21892 {
21893 dmapmap[i].format = SCRIPT_FORMAT_INVALID;
21894 }
21895 763 }
21896
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 for(int32_t i = 0; i < NUMSCRIPTSCREEN-1; ++i)
21897 {
21898
2/2
✓ Branch 0 taken 764 times.
✓ Branch 1 taken 1 times.
765 if(scripts.find(screenmap[i].scriptname) != scripts.end())
21899 {
21900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(scripts[screenmap[i].scriptname].first.script_type != ScriptType::Screen)
21901 {
21902 while(scripts.find(screenmap[i].scriptname) != scripts.end())
21903 inc_script_name(screenmap[i].scriptname);
21904 }
21905 1 else continue;
21906 }
21907
1/2
✓ Branch 0 taken 764 times.
✗ Branch 1 not taken.
764 if(!screenmap[i].isEmpty())
21908 {
21909 screenmap[i].format = SCRIPT_FORMAT_INVALID;
21910 }
21911 764 }
21912
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE-1; ++i)
21913 {
21914
1/2
✓ Branch 0 taken 765 times.
✗ Branch 1 not taken.
765 if(scripts.find(itemspritemap[i].scriptname) != scripts.end())
21915 {
21916 if(scripts[itemspritemap[i].scriptname].first.script_type != ScriptType::ItemSprite)
21917 {
21918 while(scripts.find(itemspritemap[i].scriptname) != scripts.end())
21919 inc_script_name(itemspritemap[i].scriptname);
21920 }
21921 else continue;
21922 }
21923
1/2
✓ Branch 0 taken 765 times.
✗ Branch 1 not taken.
765 if(!itemspritemap[i].isEmpty())
21924 {
21925 itemspritemap[i].format = SCRIPT_FORMAT_INVALID;
21926 }
21927 765 }
21928
2/2
✓ Branch 0 taken 1533 times.
✓ Branch 1 taken 3 times.
1536 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA-1; ++i)
21929 {
21930
1/2
✓ Branch 0 taken 1533 times.
✗ Branch 1 not taken.
1533 if(scripts.find(comboscriptmap[i].scriptname) != scripts.end())
21931 {
21932 if(scripts[comboscriptmap[i].scriptname].first.script_type != ScriptType::Combo)
21933 {
21934 while(scripts.find(comboscriptmap[i].scriptname) != scripts.end())
21935 inc_script_name(comboscriptmap[i].scriptname);
21936 }
21937 else continue;
21938 }
21939
1/2
✓ Branch 0 taken 1533 times.
✗ Branch 1 not taken.
1533 if(!comboscriptmap[i].isEmpty())
21940 {
21941 comboscriptmap[i].format = SCRIPT_FORMAT_INVALID;
21942 }
21943 1533 }
21944
2/2
✓ Branch 0 taken 1533 times.
✓ Branch 1 taken 3 times.
1536 for(int32_t i = 0; i < NUMSCRIPTSGENERIC-1; ++i)
21945 {
21946
1/2
✓ Branch 0 taken 1533 times.
✗ Branch 1 not taken.
1533 if(scripts.find(genericmap[i].scriptname) != scripts.end())
21947 {
21948 if(scripts[genericmap[i].scriptname].first.script_type != ScriptType::Generic)
21949 {
21950 while(scripts.find(genericmap[i].scriptname) != scripts.end())
21951 inc_script_name(genericmap[i].scriptname);
21952 }
21953 else continue;
21954 }
21955
1/2
✓ Branch 0 taken 1533 times.
✗ Branch 1 not taken.
1533 if(!genericmap[i].isEmpty())
21956 {
21957 genericmap[i].format = SCRIPT_FORMAT_INVALID;
21958 }
21959 1533 }
21960
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 765 times.
768 for(int32_t i = 0; i < NUMSCRIPTSSUBSCREEN-1; ++i)
21961 {
21962
1/2
✓ Branch 0 taken 765 times.
✗ Branch 1 not taken.
765 if(scripts.find(subscreenmap[i].scriptname) != scripts.end())
21963 {
21964 if(scripts[subscreenmap[i].scriptname].first.script_type != ScriptType::EngineSubscreen)
21965 {
21966 while(scripts.find(subscreenmap[i].scriptname) != scripts.end())
21967 inc_script_name(subscreenmap[i].scriptname);
21968 }
21969 else continue;
21970 }
21971
1/2
✓ Branch 0 taken 765 times.
✗ Branch 1 not taken.
765 if(!subscreenmap[i].isEmpty())
21972 {
21973 subscreenmap[i].format = SCRIPT_FORMAT_INVALID;
21974 }
21975 765 }
21976 3 }
21977
21978 enum script_slot_type
21979 {
21980 type_ffc, type_global, type_itemdata, type_npc, type_lweapon, type_eweapon,
21981 type_hero, type_dmap, type_screen, type_itemsprite, type_combo, type_generic,
21982 type_subscreen, num_types
21983 };
21984 script_slot_type getType(ScriptType type)
21985 {
21986 switch(type)
21987 {
21988 case ScriptType::FFC: return type_ffc;
21989 case ScriptType::Global: return type_global;
21990 case ScriptType::Item: return type_itemdata;
21991 case ScriptType::NPC: return type_npc;
21992 case ScriptType::Lwpn: return type_lweapon;
21993 case ScriptType::Ewpn: return type_eweapon;
21994 case ScriptType::Player: return type_hero;
21995 case ScriptType::DMap:
21996 case ScriptType::ScriptedActiveSubscreen:
21997 case ScriptType::ScriptedPassiveSubscreen:
21998 case ScriptType::OnMap:
21999 return type_dmap;
22000 case ScriptType::Generic: case ScriptType::GenericFrozen:
22001 return type_generic;
22002 case ScriptType::Screen: return type_screen;
22003 case ScriptType::ItemSprite: return type_itemsprite;
22004 case ScriptType::Combo: return type_combo;
22005 case ScriptType::EngineSubscreen: return type_subscreen;
22006 default: return type_ffc; //Default
22007 }
22008 }
22009 #define SLOTMSGFLAG_MISSING 0x01
22010 #define SLOTMSGFLAG_PRESERVED 0x02
22011 #define SLOTMSGFLAG_IMPORTED 0x04
22012 #define SLOTMSG_SIZE 512
22013 bool checkSkip(int32_t format, byte flags)
22014 {
22015 switch(format)
22016 {
22017 case SCRIPT_FORMAT_DEFAULT:
22018 return (flags != 0);
22019 case SCRIPT_FORMAT_INVALID:
22020 return ((flags & SLOTMSGFLAG_MISSING)==0);
22021 case SCRIPT_FORMAT_DISASSEMBLED:
22022 return ((flags & SLOTMSGFLAG_PRESERVED)==0);
22023 case SCRIPT_FORMAT_ZASM:
22024 return ((flags & SLOTMSGFLAG_IMPORTED)==0);
22025 default: return true;
22026 }
22027 }
22028 void clearAllSlots(int32_t type, byte flags = 0)
22029 {
22030 bound(type,0,num_types-1);
22031 switch(type)
22032 {
22033 case type_ffc:
22034 {
22035 for(int32_t q = 0; q < NUMSCRIPTFFC-1; ++q)
22036 {
22037 if(checkSkip(ffcmap[q].format, flags)) continue;
22038 ffcmap[q].scriptname = "";
22039 ffcmap[q].format = SCRIPT_FORMAT_DEFAULT;
22040 }
22041 break;
22042 }
22043 case type_global:
22044 {
22045 //Start at 1 to not clear Init
22046 for(int32_t q = 1; q < NUMSCRIPTGLOBAL; ++q)
22047 {
22048 if(checkSkip(globalmap[q].format, flags)) continue;
22049 globalmap[q].scriptname = "";
22050 globalmap[q].format = SCRIPT_FORMAT_DEFAULT;
22051 }
22052 break;
22053 }
22054 case type_itemdata:
22055 {
22056 for(int32_t q = 0; q < NUMSCRIPTITEM-1; ++q)
22057 {
22058 if(checkSkip(itemmap[q].format, flags)) continue;
22059 itemmap[q].scriptname = "";
22060 itemmap[q].format = SCRIPT_FORMAT_DEFAULT;
22061 }
22062 break;
22063 }
22064 case type_npc:
22065 {
22066 for(int32_t q = 0; q < NUMSCRIPTGUYS-1; ++q)
22067 {
22068 if(checkSkip(npcmap[q].format, flags)) continue;
22069 npcmap[q].scriptname = "";
22070 npcmap[q].format = SCRIPT_FORMAT_DEFAULT;
22071 }
22072 break;
22073 }
22074 case type_lweapon:
22075 {
22076 for(int32_t q = 0; q < NUMSCRIPTWEAPONS-1; ++q)
22077 {
22078 if(checkSkip(lwpnmap[q].format, flags)) continue;
22079 lwpnmap[q].scriptname = "";
22080 lwpnmap[q].format = SCRIPT_FORMAT_DEFAULT;
22081 }
22082 break;
22083 }
22084 case type_eweapon:
22085 {
22086 for(int32_t q = 0; q < NUMSCRIPTWEAPONS-1; ++q)
22087 {
22088 if(checkSkip(ewpnmap[q].format, flags)) continue;
22089 ewpnmap[q].scriptname = "";
22090 ewpnmap[q].format = SCRIPT_FORMAT_DEFAULT;
22091 }
22092 break;
22093 }
22094 case type_hero:
22095 {
22096 for(int32_t q = 0; q < NUMSCRIPTPLAYER-1; ++q)
22097 {
22098 if(checkSkip(playermap[q].format, flags)) continue;
22099 playermap[q].scriptname = "";
22100 playermap[q].format = SCRIPT_FORMAT_DEFAULT;
22101 }
22102 break;
22103 }
22104 case type_dmap:
22105 {
22106 for(int32_t q = 0; q < NUMSCRIPTSDMAP-1; ++q)
22107 {
22108 if(checkSkip(dmapmap[q].format, flags)) continue;
22109 dmapmap[q].scriptname = "";
22110 dmapmap[q].format = SCRIPT_FORMAT_DEFAULT;
22111 }
22112 break;
22113 }
22114 case type_screen:
22115 {
22116 for(int32_t q = 0; q < NUMSCRIPTSCREEN-1; ++q)
22117 {
22118 if(checkSkip(screenmap[q].format, flags)) continue;
22119 screenmap[q].scriptname = "";
22120 screenmap[q].format = SCRIPT_FORMAT_DEFAULT;
22121 }
22122 break;
22123 }
22124 case type_itemsprite:
22125 {
22126 for(int32_t q = 0; q < NUMSCRIPTSITEMSPRITE-1; ++q)
22127 {
22128 if(checkSkip(itemspritemap[q].format, flags)) continue;
22129 itemspritemap[q].scriptname = "";
22130 itemspritemap[q].format = SCRIPT_FORMAT_DEFAULT;
22131 }
22132 break;
22133 }
22134 case type_combo:
22135 {
22136 for(int32_t q = 0; q < NUMSCRIPTSCOMBODATA-1; ++q)
22137 {
22138 if(checkSkip(comboscriptmap[q].format, flags)) continue;
22139 comboscriptmap[q].scriptname = "";
22140 comboscriptmap[q].format = SCRIPT_FORMAT_DEFAULT;
22141 }
22142 break;
22143 }
22144 case type_generic:
22145 {
22146 for(int32_t q = 0; q < NUMSCRIPTSGENERIC-1; ++q)
22147 {
22148 if(checkSkip(genericmap[q].format, flags)) continue;
22149 genericmap[q].scriptname = "";
22150 genericmap[q].format = SCRIPT_FORMAT_DEFAULT;
22151 }
22152 break;
22153 }
22154 case type_subscreen:
22155 {
22156 for(int32_t q = 0; q < NUMSCRIPTSSUBSCREEN-1; ++q)
22157 {
22158 if(checkSkip(subscreenmap[q].format, flags)) continue;
22159 subscreenmap[q].scriptname = "";
22160 subscreenmap[q].format = SCRIPT_FORMAT_DEFAULT;
22161 }
22162 break;
22163 }
22164 }
22165 }
22166
22167 static bool doslots_log_output = false, doslots_comment_output = true;
22168 3 void setup_scriptslot_dlg(char* buf, byte flags)
22169 {
22170 //{ Set up the textbox at the bottom, and auto-resize height based on it
22171 3 int32_t prev_height = assignscript_dlg[14].h;
22172 3 memset(buf, 0, SLOTMSG_SIZE);
22173 //
22174 3 strcpy(buf, "Slots with matching names have been updated.\n");
22175
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(flags & SLOTMSGFLAG_MISSING)
22176 1 strcat(buf,"Scripts prefixed with '--' were not found, and will not function.\n");
22177
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(flags & SLOTMSGFLAG_PRESERVED)
22178 strcat(buf, "Scripts prefixed with '++' were not found, but have been preserved.\n"
22179 " These scripts may not function correctly if they use global variables.\n");
22180
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(flags & SLOTMSGFLAG_IMPORTED)
22181 strcat(buf,"Scripts prefixed with '==' are imported ZASM scripts.\n");
22182 3 strcat(buf,"Global scripts named 'Init' will be appended to '~Init'");
22183 //
22184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 SETFLAG(assignscript_dlg[13].flags, D_SELECTED, doslots_log_output);
22185
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 SETFLAG(assignscript_dlg[51].flags, D_SELECTED, doslots_comment_output);
22186 3 assignscript_dlg[14].dp = buf;
22187 3 object_message(&assignscript_dlg[14], MSG_START, 0); //Set the width/height
22188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(int32_t diff = assignscript_dlg[14].h - prev_height) //resize dlg
22189 {
22190 3 int32_t prev_bottom = assignscript_dlg[14].y + prev_height;
22191
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 3 times.
156 for(int32_t q = 1; assignscript_dlg[q].proc; ++q)
22192 {
22193
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 150 times.
153 if(q==14) continue; //Don't change self
22194
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 12 times.
150 if(assignscript_dlg[q].y < prev_bottom) continue; //above proc
22195 12 assignscript_dlg[q].y += diff;
22196 12 }
22197 3 assignscript_dlg[0].h += diff;
22198 3 jwin_center_dialog(assignscript_dlg);
22199 3 }
22200 //}
22201 3 }
22202
22203 std::string global_slotnames[NUMSCRIPTGLOBAL] = {
22204 "Init",
22205 "Active",
22206 "onExit",
22207 "onSaveLoad",
22208 "onLaunch",
22209 "onContGame",
22210 "onF6Menu",
22211 "onSave",
22212 };
22213 std::string player_slotnames[NUMSCRIPTPLAYER-1] = {
22214 "Init",
22215 "Active",
22216 "onDeath",
22217 "onWin",
22218 };
22219 3 byte reload_scripts(map<string, disassembled_script_data> &scripts)
22220 {
22221 3 byte slotflags = 0;
22222 char temp[100];
22223
2/2
✓ Branch 0 taken 1533 times.
✓ Branch 1 taken 3 times.
1536 for(int32_t i = 0; i < NUMSCRIPTFFC-1; i++)
22224 {
22225
2/2
✓ Branch 0 taken 1469 times.
✓ Branch 1 taken 64 times.
1533 if(ffcmap[i].isEmpty())
22226 1469 sprintf(temp, "Slot %d:", i+1);
22227 else
22228 {
22229 64 sprintf(temp, "Slot %d:", i+1);
22230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(ffcmap[i].isZASM())
22231 {
22232 if(ffcmap[i].isImportedZASM()) slotflags |= SLOTMSGFLAG_IMPORTED;
22233 else slotflags |= SLOTMSGFLAG_PRESERVED;
22234 }
22235
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 1 times.
64 else if(scripts.find(ffcmap[i].scriptname) != scripts.end())
22236 63 ffcmap[i].format = SCRIPT_FORMAT_DEFAULT;
22237 else // Previously loaded script not found
22238 {
22239 1 ffcmap[i].format = SCRIPT_FORMAT_INVALID;
22240 1 slotflags |= SLOTMSGFLAG_MISSING;
22241 }
22242 }
22243 1533 ffcmap[i].slotname = temp;
22244 1533 ffcmap[i].update();
22245 1533 }
22246
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 3 times.
27 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; i++)
22247 {
22248
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 globalmap[i].slotname=fmt::format("{}:",global_slotnames[i]);
22249
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(!globalmap[i].isEmpty())
22250 {
22251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(globalmap[i].isZASM())
22252 {
22253 if(globalmap[i].isImportedZASM()) slotflags |= SLOTMSGFLAG_IMPORTED;
22254 else slotflags |= SLOTMSGFLAG_PRESERVED;
22255 }
22256
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 else if(scripts.find(globalmap[i].scriptname) != scripts.end() || globalmap[i].scriptname == "~Init")
22257 6 globalmap[i].format = SCRIPT_FORMAT_DEFAULT;
22258 else // Unloaded
22259 {
22260 globalmap[i].format = SCRIPT_FORMAT_INVALID;
22261 slotflags |= SLOTMSGFLAG_MISSING;
22262 }
22263 6 }
22264 24 globalmap[i].update();
22265 24 }
22266
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 for(int32_t i = 0; i < NUMSCRIPTITEM-1; i++)
22267 {
22268
2/2
✓ Branch 0 taken 754 times.
✓ Branch 1 taken 11 times.
765 if(itemmap[i].isEmpty())
22269 754 sprintf(temp, "Slot %d:", i+1);
22270 else
22271 {
22272 11 sprintf(temp, "Slot %d:", i+1);
22273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(itemmap[i].isZASM())
22274 {
22275 if(itemmap[i].isImportedZASM()) slotflags |= SLOTMSGFLAG_IMPORTED;
22276 else slotflags |= SLOTMSGFLAG_PRESERVED;
22277 }
22278
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 else if(scripts.find(itemmap[i].scriptname) != scripts.end())
22279 11 itemmap[i].format = SCRIPT_FORMAT_DEFAULT;
22280 else // Previously loaded script not found
22281 {
22282 itemmap[i].format = SCRIPT_FORMAT_INVALID;
22283 slotflags |= SLOTMSGFLAG_MISSING;
22284 }
22285 }
22286 765 itemmap[i].slotname = temp;
22287 765 itemmap[i].update();
22288 765 }
22289
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 for(int32_t i = 0; i < NUMSCRIPTGUYS-1; i++)
22290 {
22291
1/2
✓ Branch 0 taken 765 times.
✗ Branch 1 not taken.
765 if(npcmap[i].isEmpty())
22292 765 sprintf(temp, "Slot %d:", i+1);
22293 else
22294 {
22295 sprintf(temp, "Slot %d:", i+1);
22296 if(npcmap[i].isZASM())
22297 {
22298 if(npcmap[i].isImportedZASM()) slotflags |= SLOTMSGFLAG_IMPORTED;
22299 else slotflags |= SLOTMSGFLAG_PRESERVED;
22300 }
22301 else if(scripts.find(npcmap[i].scriptname) != scripts.end())
22302 npcmap[i].format = SCRIPT_FORMAT_DEFAULT;
22303 else // Previously loaded script not found
22304 {
22305 npcmap[i].format = SCRIPT_FORMAT_INVALID;
22306 slotflags |= SLOTMSGFLAG_MISSING;
22307 }
22308 }
22309 765 npcmap[i].slotname = temp;
22310 765 npcmap[i].update();
22311 765 }
22312
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 for(int32_t i = 0; i < NUMSCRIPTWEAPONS-1; i++)
22313 {
22314
1/2
✓ Branch 0 taken 765 times.
✗ Branch 1 not taken.
765 if(ewpnmap[i].isEmpty())
22315 765 sprintf(temp, "Slot %d:", i+1);
22316 else
22317 {
22318 sprintf(temp, "Slot %d:", i+1);
22319 if(ewpnmap[i].isZASM())
22320 {
22321 if(ewpnmap[i].isImportedZASM()) slotflags |= SLOTMSGFLAG_IMPORTED;
22322 else slotflags |= SLOTMSGFLAG_PRESERVED;
22323 }
22324 else if(scripts.find(ewpnmap[i].scriptname) != scripts.end())
22325 ewpnmap[i].format = SCRIPT_FORMAT_DEFAULT;
22326 else // Previously loaded script not found
22327 {
22328 ewpnmap[i].format = SCRIPT_FORMAT_INVALID;
22329 slotflags |= SLOTMSGFLAG_MISSING;
22330 }
22331 }
22332 765 ewpnmap[i].slotname = temp;
22333 765 ewpnmap[i].update();
22334 765 }
22335
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 for(int32_t i = 0; i < NUMSCRIPTWEAPONS-1; i++)
22336 {
22337
1/2
✓ Branch 0 taken 765 times.
✗ Branch 1 not taken.
765 if(lwpnmap[i].isEmpty())
22338 765 sprintf(temp, "Slot %d:", i+1);
22339 else
22340 {
22341 sprintf(temp, "Slot %d:", i+1);
22342 if(lwpnmap[i].isZASM())
22343 {
22344 if(lwpnmap[i].isImportedZASM()) slotflags |= SLOTMSGFLAG_IMPORTED;
22345 else slotflags |= SLOTMSGFLAG_PRESERVED;
22346 }
22347 else if(scripts.find(lwpnmap[i].scriptname) != scripts.end())
22348 lwpnmap[i].format = SCRIPT_FORMAT_DEFAULT;
22349 else // Previously loaded script not found
22350 {
22351 lwpnmap[i].format = SCRIPT_FORMAT_INVALID;
22352 slotflags |= SLOTMSGFLAG_MISSING;
22353 }
22354 }
22355 765 lwpnmap[i].slotname = temp;
22356 765 lwpnmap[i].update();
22357 765 }
22358
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t i = 0; i < NUMSCRIPTPLAYER-1; i++)
22359 {
22360
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 playermap[i].slotname=fmt::format("{}:",player_slotnames[i]);
22361
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!playermap[i].isEmpty())
22362 {
22363 if(playermap[i].isZASM())
22364 {
22365 if(playermap[i].isImportedZASM()) slotflags |= SLOTMSGFLAG_IMPORTED;
22366 else slotflags |= SLOTMSGFLAG_PRESERVED;
22367 }
22368 else if(scripts.find(playermap[i].scriptname) != scripts.end())
22369 playermap[i].format = SCRIPT_FORMAT_DEFAULT;
22370 else // Unloaded
22371 {
22372 playermap[i].format = SCRIPT_FORMAT_INVALID;
22373 slotflags |= SLOTMSGFLAG_MISSING;
22374 }
22375 }
22376 12 playermap[i].update();
22377 12 }
22378
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 for(int32_t i = 0; i < NUMSCRIPTSCREEN-1; i++)
22379 {
22380
2/2
✓ Branch 0 taken 764 times.
✓ Branch 1 taken 1 times.
765 if(screenmap[i].isEmpty())
22381 764 sprintf(temp, "Slot %d:", i+1);
22382 else
22383 {
22384 1 sprintf(temp, "Slot %d:", i+1);
22385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(screenmap[i].isZASM())
22386 {
22387 if(screenmap[i].isImportedZASM()) slotflags |= SLOTMSGFLAG_IMPORTED;
22388 else slotflags |= SLOTMSGFLAG_PRESERVED;
22389 }
22390
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 else if(scripts.find(screenmap[i].scriptname) != scripts.end())
22391 1 screenmap[i].format = SCRIPT_FORMAT_DEFAULT;
22392 else // Previously loaded script not found
22393 {
22394 screenmap[i].format = SCRIPT_FORMAT_INVALID;
22395 slotflags |= SLOTMSGFLAG_MISSING;
22396 }
22397 }
22398 765 screenmap[i].slotname = temp;
22399 765 screenmap[i].update();
22400 765 }
22401
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 for(int32_t i = 0; i < NUMSCRIPTSDMAP-1; i++)
22402 {
22403
2/2
✓ Branch 0 taken 763 times.
✓ Branch 1 taken 2 times.
765 if(dmapmap[i].isEmpty())
22404 763 sprintf(temp, "Slot %d:", i+1);
22405 else
22406 {
22407 2 sprintf(temp, "Slot %d:", i+1);
22408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(dmapmap[i].isZASM())
22409 {
22410 if(dmapmap[i].isImportedZASM()) slotflags |= SLOTMSGFLAG_IMPORTED;
22411 else slotflags |= SLOTMSGFLAG_PRESERVED;
22412 }
22413
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 else if(scripts.find(dmapmap[i].scriptname) != scripts.end())
22414 2 dmapmap[i].format = SCRIPT_FORMAT_DEFAULT;
22415 else // Previously loaded script not found
22416 {
22417 dmapmap[i].format = SCRIPT_FORMAT_INVALID;
22418 slotflags |= SLOTMSGFLAG_MISSING;
22419 }
22420 }
22421 765 dmapmap[i].slotname = temp;
22422 765 dmapmap[i].update();
22423 765 }
22424
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE-1; i++)
22425 {
22426
1/2
✓ Branch 0 taken 765 times.
✗ Branch 1 not taken.
765 if(itemspritemap[i].isEmpty())
22427 765 sprintf(temp, "Slot %d:", i+1);
22428 else
22429 {
22430 sprintf(temp, "Slot %d:", i+1);
22431 if(itemspritemap[i].isZASM())
22432 {
22433 if(itemspritemap[i].isImportedZASM()) slotflags |= SLOTMSGFLAG_IMPORTED;
22434 else slotflags |= SLOTMSGFLAG_PRESERVED;
22435 }
22436 else if(scripts.find(itemspritemap[i].scriptname) != scripts.end())
22437 itemspritemap[i].format = SCRIPT_FORMAT_DEFAULT;
22438 else // Previously loaded script not found
22439 {
22440 itemspritemap[i].format = SCRIPT_FORMAT_INVALID;
22441 slotflags |= SLOTMSGFLAG_MISSING;
22442 }
22443 }
22444 765 itemspritemap[i].slotname = temp;
22445 765 itemspritemap[i].update();
22446 765 }
22447
2/2
✓ Branch 0 taken 1533 times.
✓ Branch 1 taken 3 times.
1536 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA-1; i++)
22448 {
22449
1/2
✓ Branch 0 taken 1533 times.
✗ Branch 1 not taken.
1533 if(comboscriptmap[i].isEmpty())
22450 1533 sprintf(temp, "Slot %d:", i+1);
22451 else
22452 {
22453 sprintf(temp, "Slot %d:", i+1);
22454 if(comboscriptmap[i].isZASM())
22455 {
22456 if(comboscriptmap[i].isImportedZASM()) slotflags |= SLOTMSGFLAG_IMPORTED;
22457 else slotflags |= SLOTMSGFLAG_PRESERVED;
22458 }
22459 else if(scripts.find(comboscriptmap[i].scriptname) != scripts.end())
22460 comboscriptmap[i].format = SCRIPT_FORMAT_DEFAULT;
22461 else // Previously loaded script not found
22462 {
22463 comboscriptmap[i].format = SCRIPT_FORMAT_INVALID;
22464 slotflags |= SLOTMSGFLAG_MISSING;
22465 }
22466 }
22467 1533 comboscriptmap[i].slotname = temp;
22468 1533 comboscriptmap[i].update();
22469 1533 }
22470
2/2
✓ Branch 0 taken 1533 times.
✓ Branch 1 taken 3 times.
1536 for(int32_t i = 0; i < NUMSCRIPTSGENERIC-1; i++)
22471 {
22472
1/2
✓ Branch 0 taken 1533 times.
✗ Branch 1 not taken.
1533 if(genericmap[i].isEmpty())
22473 1533 sprintf(temp, "Slot %d:", i+1);
22474 else
22475 {
22476 sprintf(temp, "Slot %d:", i+1);
22477 if(genericmap[i].isZASM())
22478 {
22479 if(genericmap[i].isImportedZASM()) slotflags |= SLOTMSGFLAG_IMPORTED;
22480 else slotflags |= SLOTMSGFLAG_PRESERVED;
22481 }
22482 else if(scripts.find(genericmap[i].scriptname) != scripts.end())
22483 genericmap[i].format = SCRIPT_FORMAT_DEFAULT;
22484 else // Previously loaded script not found
22485 {
22486 genericmap[i].format = SCRIPT_FORMAT_INVALID;
22487 slotflags |= SLOTMSGFLAG_MISSING;
22488 }
22489 }
22490 1533 genericmap[i].slotname = temp;
22491 1533 genericmap[i].update();
22492 1533 }
22493
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 for(int32_t i = 0; i < NUMSCRIPTSSUBSCREEN-1; i++)
22494 {
22495
1/2
✓ Branch 0 taken 765 times.
✗ Branch 1 not taken.
765 if(subscreenmap[i].isEmpty())
22496 765 sprintf(temp, "Slot %d:", i+1);
22497 else
22498 {
22499 sprintf(temp, "Slot %d:", i+1);
22500 if(subscreenmap[i].isZASM())
22501 {
22502 if(subscreenmap[i].isImportedZASM()) slotflags |= SLOTMSGFLAG_IMPORTED;
22503 else slotflags |= SLOTMSGFLAG_PRESERVED;
22504 }
22505 else if(scripts.find(subscreenmap[i].scriptname) != scripts.end())
22506 subscreenmap[i].format = SCRIPT_FORMAT_DEFAULT;
22507 else // Previously loaded script not found
22508 {
22509 subscreenmap[i].format = SCRIPT_FORMAT_INVALID;
22510 slotflags |= SLOTMSGFLAG_MISSING;
22511 }
22512 }
22513 765 subscreenmap[i].slotname = temp;
22514 765 subscreenmap[i].update();
22515 765 }
22516 3 return slotflags;
22517 }
22518
22519 void doClearSlots(byte* flags);
22520
22521 extern byte compile_success_sample, compile_error_sample,
22522 compile_finish_sample, compile_audio_volume;
22523 static map<string, disassembled_script_data> *doslot_scripts = nullptr;
22524 10755 bool handle_slot(script_slot_data& slotdata, int indx, script_data** scriptdata)
22525 {
22526
2/2
✓ Branch 0 taken 10672 times.
✓ Branch 1 taken 83 times.
10755 if(slotdata.hasScriptData())
22527 {
22528 83 string scriptstr;
22529
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 (*doslot_scripts)[slotdata.scriptname].write(scriptstr, doslots_log_output, false, doslots_comment_output);
22530
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 parse_script_string(&scriptdata[indx],scriptstr,false);
22531
22532
2/6
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 83 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
83 if(slotdata.isDisassembled()) scriptdata[indx]->meta.setFlag(ZMETA_DISASSEMBLED);
22533
2/6
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 83 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
83 else if(slotdata.isImportedZASM()) scriptdata[indx]->meta.setFlag(ZMETA_IMPORTED);
22534 83 }
22535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10672 times.
10672 else if(scriptdata[indx])
22536 {
22537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10672 times.
10672 delete scriptdata[indx];
22538 // script_data::id is not used in editor, so should be fine for now.
22539
1/2
✓ Branch 0 taken 10672 times.
✗ Branch 1 not taken.
10672 scriptdata[indx] = new script_data(ScriptType::None, 0);
22540 10672 }
22541 10755 return true;
22542 }
22543 39 bool handle_slot_map(map<int32_t, script_slot_data>& mp, int offs, script_data** scriptdata)
22544 {
22545
2/2
✓ Branch 0 taken 10755 times.
✓ Branch 1 taken 39 times.
10794 for(auto it = mp.begin(); it != mp.end(); it++)
22546 {
22547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10755 times.
10755 if(!handle_slot(it->second, it->first+offs, scriptdata))
22548 return false;
22549 10755 }
22550 39 return true;
22551 39 }
22552
22553 void smart_slot_named(map<string, disassembled_script_data> &scripts,
22554 vector<string> const& scriptnames, map<int32_t, script_slot_data>& mp,
22555 std::string* slotnames, int slotstart, int slotend)
22556 {
22557 for(int q = slotstart; q < slotend; ++q)
22558 {
22559 auto& lval = mp[q];
22560 if(!lval.isEmpty())
22561 continue; //occupied, leave alone
22562 bool done = false;
22563 if(!done) //Check case-sensitive
22564 for(size_t rind = 0; rind < scriptnames.size(); ++rind)
22565 {
22566 auto const& rval = scriptnames[rind];
22567 if(rval == "<none>") continue;
22568 if(rval == slotnames[q])
22569 { //Perfect match
22570 lval.updateName(rval);
22571 lval.format = scripts[lval.scriptname].format;
22572 done = true;
22573 break;
22574 }
22575 }
22576 if(!done) //Check case-insensitive
22577 for(size_t rind = 0; rind < scriptnames.size(); ++rind)
22578 {
22579 auto const& rval = scriptnames[rind];
22580 if(rval == "<none>") continue;
22581 string lc_rv = rval, lc_slot = slotnames[q];
22582 lowerstr(lc_rv);
22583 lowerstr(lc_slot);
22584 if(lc_rv == lc_slot)
22585 { //Insensitive match
22586 lval.updateName(rval);
22587 lval.format = scripts[lval.scriptname].format;
22588 break;
22589 }
22590 }
22591 }
22592 }
22593 void smart_slot_type(map<string, disassembled_script_data> &scripts,
22594 vector<string> const& scriptnames, map<int32_t, script_slot_data>& mp,
22595 int slotcount)
22596 {
22597 for(size_t rind = 0; rind < scriptnames.size(); ++rind)
22598 {
22599 auto const& rval = scriptnames[rind];
22600 if(rval == "<none>") continue;
22601 script_slot_data* first_open_slot = nullptr;
22602 bool done = false;
22603 for(int q = 0; q < slotcount; ++q)
22604 {
22605 auto& lval = mp[q];
22606 if(lval.isEmpty())
22607 {
22608 if(!first_open_slot)
22609 first_open_slot = &lval;
22610 }
22611 else if(lval.scriptname == rval)
22612 {
22613 done = true;
22614 break;
22615 }
22616 }
22617 if(!done)
22618 {
22619 if(!first_open_slot)
22620 break; //no slots left to assign to!
22621 first_open_slot->updateName(rval);
22622 first_open_slot->format = scripts[first_open_slot->scriptname].format;
22623 }
22624 }
22625 }
22626
22627 3 bool do_slots(map<string, disassembled_script_data> &scripts, int assign_mode)
22628 {
22629 3 large_dialog(assignscript_dlg);
22630 3 int32_t ret = 3;
22631 3 char slots_msg[SLOTMSG_SIZE] = {0};
22632 3 byte slotflags = reload_scripts(scripts);
22633 3 setup_scriptslot_dlg(slots_msg, slotflags);
22634 3 bool retval = false;
22635
22636 3 popup_zqdialog_start();
22637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 while(!assign_mode)
22638 {
22639 slotflags = reload_scripts(scripts);
22640 ret = do_zqdialog(assignscript_dlg, ret);
22641
22642 switch(ret)
22643 {
22644 case 0:
22645 case 2:
22646 //Cancel
22647 goto exit_do_slots;
22648
22649 case 3: goto auto_do_slots;
22650
22651 case 6:
22652 //<<, FFC
22653 {
22654 int32_t lind = assignscript_dlg[4].d1;
22655 int32_t rind = assignscript_dlg[5].d1;
22656
22657 if(lind < 0 || rind < 0)
22658 break;
22659
22660 if(asffcscripts[rind] == "<none>")
22661 {
22662 ffcmap[lind].scriptname = "";
22663 ffcmap[lind].format = SCRIPT_FORMAT_DEFAULT;
22664 }
22665 else
22666 {
22667 ffcmap[lind].updateName(asffcscripts[rind]);
22668 ffcmap[lind].format = scripts[ffcmap[lind].scriptname].format;
22669 }
22670
22671 break;
22672 }
22673 case 9:
22674 //<<, Global
22675 {
22676 int32_t lind = assignscript_dlg[7].d1;
22677 int32_t rind = assignscript_dlg[8].d1;
22678
22679 if(lind < 0 || rind < 0)
22680 break;
22681
22682 if(lind == 0)
22683 {
22684 jwin_alert("Error","ZScript reserves this slot.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
22685 break;
22686 }
22687
22688 if(asglobalscripts[rind] == "<none>")
22689 {
22690 globalmap[lind].scriptname = "";
22691 globalmap[lind].format = SCRIPT_FORMAT_DEFAULT;
22692 }
22693 else
22694 {
22695 globalmap[lind].updateName(asglobalscripts[rind]);
22696 globalmap[lind].format = scripts[globalmap[lind].scriptname].format;
22697 }
22698
22699 break;
22700 }
22701 case 12:
22702 //<<, ITEM
22703 {
22704 int32_t lind = assignscript_dlg[10].d1;
22705 int32_t rind = assignscript_dlg[11].d1;
22706
22707 if(lind < 0 || rind < 0)
22708 break;
22709
22710 if(asitemscripts[rind] == "<none>")
22711 {
22712 itemmap[lind].scriptname = "";
22713 itemmap[lind].format = SCRIPT_FORMAT_DEFAULT;
22714 }
22715 else
22716 {
22717 itemmap[lind].updateName(asitemscripts[rind]);
22718 itemmap[lind].format = scripts[itemmap[lind].scriptname].format;
22719 }
22720
22721 break;
22722 }
22723 case 20:
22724 //<<, NPC
22725 {
22726 int32_t lind = assignscript_dlg[18].d1;
22727 int32_t rind = assignscript_dlg[19].d1;
22728
22729 if(lind < 0 || rind < 0)
22730 break;
22731
22732 if(asnpcscripts[rind] == "<none>")
22733 {
22734 npcmap[lind].scriptname = "";
22735 npcmap[lind].format = SCRIPT_FORMAT_DEFAULT;
22736 }
22737 else
22738 {
22739 npcmap[lind].updateName(asnpcscripts[rind]);
22740 npcmap[lind].format = scripts[npcmap[lind].scriptname].format;
22741 }
22742
22743 break;
22744 }
22745 case 23:
22746 //<<, LWeapon
22747 {
22748 int32_t lind = assignscript_dlg[21].d1;
22749 int32_t rind = assignscript_dlg[22].d1;
22750
22751 if(lind < 0 || rind < 0)
22752 break;
22753
22754 if(aslweaponscripts[rind] == "<none>")
22755 {
22756 lwpnmap[lind].scriptname = "";
22757 lwpnmap[lind].format = SCRIPT_FORMAT_DEFAULT;
22758 }
22759 else
22760 {
22761 lwpnmap[lind].updateName(aslweaponscripts[rind]);
22762 lwpnmap[lind].format = scripts[lwpnmap[lind].scriptname].format;
22763 }
22764
22765 break;
22766 }
22767 case 26:
22768 //<<, EWeapon
22769 {
22770 int32_t lind = assignscript_dlg[24].d1;
22771 int32_t rind = assignscript_dlg[25].d1;
22772
22773 if(lind < 0 || rind < 0)
22774 break;
22775
22776 if(aseweaponscripts[rind] == "<none>")
22777 {
22778 ewpnmap[lind].scriptname = "";
22779 ewpnmap[lind].format = SCRIPT_FORMAT_DEFAULT;
22780 }
22781 else
22782 {
22783 ewpnmap[lind].updateName(aseweaponscripts[rind]);
22784 ewpnmap[lind].format = scripts[ewpnmap[lind].scriptname].format;
22785 }
22786
22787 break;
22788 }
22789 case 29:
22790 //<<, Player
22791 {
22792 int32_t lind = assignscript_dlg[27].d1;
22793 int32_t rind = assignscript_dlg[28].d1;
22794
22795 if(lind < 0 || rind < 0)
22796 break;
22797
22798 if(asplayerscripts[rind] == "<none>")
22799 {
22800 playermap[lind].scriptname = "";
22801 playermap[lind].format = SCRIPT_FORMAT_DEFAULT;
22802 }
22803 else
22804 {
22805 playermap[lind].updateName(asplayerscripts[rind]);
22806 playermap[lind].format = scripts[playermap[lind].scriptname].format;
22807 }
22808
22809 break;
22810 }
22811 case 32:
22812 //<<, Screendata
22813 {
22814 int32_t lind = assignscript_dlg[30].d1;
22815 int32_t rind = assignscript_dlg[31].d1;
22816
22817 if(lind < 0 || rind < 0)
22818 break;
22819
22820 if(asscreenscripts[rind] == "<none>")
22821 {
22822 screenmap[lind].scriptname = "";
22823 screenmap[lind].format = SCRIPT_FORMAT_DEFAULT;
22824 }
22825 else
22826 {
22827 screenmap[lind].updateName(asscreenscripts[rind]);
22828 screenmap[lind].format = scripts[screenmap[lind].scriptname].format;
22829 }
22830
22831 break;
22832 }
22833 case 35:
22834 //<<, dmapdata
22835 {
22836 int32_t lind = assignscript_dlg[33].d1;
22837 int32_t rind = assignscript_dlg[34].d1;
22838
22839 if(lind < 0 || rind < 0)
22840 break;
22841
22842 if(asdmapscripts[rind] == "<none>")
22843 {
22844 dmapmap[lind].scriptname = "";
22845 dmapmap[lind].format = SCRIPT_FORMAT_DEFAULT;
22846 }
22847 else
22848 {
22849 dmapmap[lind].updateName(asdmapscripts[rind]);
22850 dmapmap[lind].format = scripts[dmapmap[lind].scriptname].format;
22851 }
22852
22853 break;
22854 }
22855 case 38:
22856 //<<, itemsprite
22857 {
22858 int32_t lind = assignscript_dlg[36].d1;
22859 int32_t rind = assignscript_dlg[37].d1;
22860
22861 if(lind < 0 || rind < 0)
22862 break;
22863
22864 if(asitemspritescripts[rind] == "<none>")
22865 {
22866 itemspritemap[lind].scriptname = "";
22867 itemspritemap[lind].format = SCRIPT_FORMAT_DEFAULT;
22868 }
22869 else
22870 {
22871 itemspritemap[lind].updateName(asitemspritescripts[rind]);
22872 itemspritemap[lind].format = scripts[itemspritemap[lind].scriptname].format;
22873 }
22874
22875 break;
22876 }
22877 case 41:
22878 //<<, comboscript
22879 {
22880 int32_t lind = assignscript_dlg[39].d1;
22881 int32_t rind = assignscript_dlg[40].d1;
22882
22883 if(lind < 0 || rind < 0)
22884 break;
22885
22886 if(ascomboscripts[rind] == "<none>")
22887 {
22888 comboscriptmap[lind].scriptname = "";
22889 comboscriptmap[lind].format = SCRIPT_FORMAT_DEFAULT;
22890 }
22891 else
22892 {
22893 comboscriptmap[lind].updateName(ascomboscripts[rind]);
22894 comboscriptmap[lind].format = scripts[comboscriptmap[lind].scriptname].format;
22895 }
22896
22897 break;
22898 }
22899 case 47:
22900 //<<, generic script
22901 {
22902 int32_t lind = assignscript_dlg[45].d1;
22903 int32_t rind = assignscript_dlg[46].d1;
22904
22905 if(lind < 0 || rind < 0)
22906 break;
22907
22908 if(asgenericscripts[rind] == "<none>")
22909 {
22910 genericmap[lind].scriptname = "";
22911 genericmap[lind].format = SCRIPT_FORMAT_DEFAULT;
22912 }
22913 else
22914 {
22915 genericmap[lind].updateName(asgenericscripts[rind]);
22916 genericmap[lind].format = scripts[genericmap[lind].scriptname].format;
22917 }
22918
22919 break;
22920 }
22921 case 50:
22922 //<<, subscreen script
22923 {
22924 int32_t lind = assignscript_dlg[48].d1;
22925 int32_t rind = assignscript_dlg[49].d1;
22926
22927 if(lind < 0 || rind < 0)
22928 break;
22929
22930 if(assubscreenscripts[rind] == "<none>")
22931 {
22932 subscreenmap[lind].scriptname = "";
22933 subscreenmap[lind].format = SCRIPT_FORMAT_DEFAULT;
22934 }
22935 else
22936 {
22937 subscreenmap[lind].updateName(assubscreenscripts[rind]);
22938 subscreenmap[lind].format = scripts[subscreenmap[lind].scriptname].format;
22939 }
22940
22941 break;
22942 }
22943
22944 case 42:
22945 //Script Info, information
22946 {
22947 disassembled_script_data* target = nullptr;
22948 switch(get_selected_tab((TABPANEL*)assignscript_dlg[1].dp))
22949 {
22950 default:
22951 case 0: //FFC
22952 {
22953 int32_t id = assignscript_dlg[4].d1;
22954 if(id > -1 && ffcmap[id].hasScriptData())
22955 {
22956 target = &(scripts[ffcmap[id].scriptname]);
22957 }
22958 break;
22959 }
22960 case 1: //Global
22961 {
22962 int32_t id = assignscript_dlg[7].d1;
22963 if(id > -1 && globalmap[id].hasScriptData())
22964 {
22965 target = &(scripts[globalmap[id].scriptname]);
22966 }
22967 break;
22968 }
22969 case 2: //Item
22970 {
22971 int32_t id = assignscript_dlg[10].d1;
22972 if(id > -1 && itemmap[id].hasScriptData())
22973 {
22974 target = &(scripts[itemmap[id].scriptname]);
22975 }
22976 break;
22977 }
22978 case 3: //npc
22979 {
22980 int32_t id = assignscript_dlg[19].d1;
22981 if(id > -1 && npcmap[id].hasScriptData())
22982 {
22983 target = &(scripts[npcmap[id].scriptname]);
22984 }
22985 break;
22986 }
22987 case 4: //lweapon
22988 {
22989 int32_t id = assignscript_dlg[21].d1;
22990 if(id > -1 && lwpnmap[id].hasScriptData())
22991 {
22992 target = &(scripts[lwpnmap[id].scriptname]);
22993 }
22994 break;
22995 }
22996 case 5: //eweapon
22997 {
22998 int32_t id = assignscript_dlg[24].d1;
22999 if(id > -1 && ewpnmap[id].hasScriptData())
23000 {
23001 target = &(scripts[ewpnmap[id].scriptname]);
23002 }
23003 break;
23004 }
23005 case 6: //hero
23006 {
23007 int32_t id = assignscript_dlg[27].d1;
23008 if(id > -1 && playermap[id].hasScriptData())
23009 {
23010 target = &(scripts[playermap[id].scriptname]);
23011 }
23012 break;
23013 }
23014 case 7: //dmap
23015 {
23016 int32_t id = assignscript_dlg[33].d1;
23017 if(id > -1 && dmapmap[id].hasScriptData())
23018 {
23019 target = &(scripts[dmapmap[id].scriptname]);
23020 }
23021 break;
23022 }
23023 case 8: //screen
23024 {
23025 int32_t id = assignscript_dlg[30].d1;
23026 if(id > -1 && screenmap[id].hasScriptData())
23027 {
23028 target = &(scripts[screenmap[id].scriptname]);
23029 }
23030 break;
23031 }
23032 case 9: //itemsprite
23033 {
23034 int32_t id = assignscript_dlg[36].d1;
23035 if(id > -1 && itemspritemap[id].hasScriptData())
23036 {
23037 target = &(scripts[itemspritemap[id].scriptname]);
23038 }
23039 break;
23040 }
23041 case 10: //combo
23042 {
23043 int32_t id = assignscript_dlg[39].d1;
23044 if(id > -1 && comboscriptmap[id].hasScriptData())
23045 {
23046 target = &(scripts[comboscriptmap[id].scriptname]);
23047 }
23048 break;
23049 }
23050 case 11: //Generic
23051 {
23052 int32_t id = assignscript_dlg[45].d1;
23053 if(id > -1 && genericmap[id].hasScriptData())
23054 {
23055 target = &(scripts[genericmap[id].scriptname]);
23056 }
23057 break;
23058 }
23059 case 12: //Subscreen
23060 {
23061 int32_t id = assignscript_dlg[48].d1;
23062 if(id > -1 && subscreenmap[id].hasScriptData())
23063 {
23064 target = &(scripts[subscreenmap[id].scriptname]);
23065 }
23066 break;
23067 }
23068 }
23069 zasm_meta* meta = target ? &target->first : nullptr;
23070 if(devpwd() && CHECK_CTRL_CMD)
23071 {
23072 string str;
23073 target->write(str, false, false, (assignscript_dlg[51].flags == D_SELECTED), true);
23074 set_al_clipboard(str);
23075 displayinfo("Clipboard Copy","Copied ZASM of selected script to clipboard");
23076 }
23077 else if(meta)
23078 showScriptInfo(meta);
23079 break;
23080 }
23081
23082 case 43:
23083 //Script Info, information
23084 {
23085 disassembled_script_data* target = NULL;
23086 switch(get_selected_tab((TABPANEL*)assignscript_dlg[1].dp))
23087 {
23088 default:
23089 case 0: //FFC
23090 {
23091 int32_t id = assignscript_dlg[5].d1;
23092 if(id < 0 || asffcscripts[id] == "<none>" || asffcscripts[id].at(0) == '-') break;
23093 target = &(scripts[asffcscripts[id]]);
23094 break;
23095 }
23096 case 1: //Global
23097 {
23098 int32_t id = assignscript_dlg[8].d1;
23099 if(id < 0 || asglobalscripts[id] == "<none>" || asglobalscripts[id].at(0) == '-') break;
23100 target = &(scripts[asglobalscripts[id]]);
23101 break;
23102 }
23103 case 2: //Item
23104 {
23105 int32_t id = assignscript_dlg[11].d1;
23106 if(id < 0 || asitemscripts[id] == "<none>" || asitemscripts[id].at(0) == '-') break;
23107 target = &(scripts[asitemscripts[id]]);
23108 break;
23109 }
23110 case 3: //npc
23111 {
23112 int32_t id = assignscript_dlg[20].d1;
23113 if(id < 0 || asnpcscripts[id] == "<none>" || asnpcscripts[id].at(0) == '-') break;
23114 target = &(scripts[asnpcscripts[id]]);
23115 break;
23116 }
23117 case 4: //lweapon
23118 {
23119 int32_t id = assignscript_dlg[22].d1;
23120 if(id < 0 || aslweaponscripts[id] == "<none>" || aslweaponscripts[id].at(0) == '-') break;
23121 target = &(scripts[aslweaponscripts[id]]);
23122 break;
23123 }
23124 case 5: //eweapon
23125 {
23126 int32_t id = assignscript_dlg[25].d1;
23127 if(id < 0 || aseweaponscripts[id] == "<none>" || aseweaponscripts[id].at(0) == '-') break;
23128 target = &(scripts[aseweaponscripts[id]]);
23129 break;
23130 }
23131 case 6: //hero
23132 {
23133 int32_t id = assignscript_dlg[28].d1;
23134 if(id < 0 || asplayerscripts[id] == "<none>" || asplayerscripts[id].at(0) == '-') break;
23135 target = &(scripts[asplayerscripts[id]]);
23136 break;
23137 }
23138 case 7: //dmap
23139 {
23140 int32_t id = assignscript_dlg[34].d1;
23141 if(id < 0 || asdmapscripts[id] == "<none>" || asdmapscripts[id].at(0) == '-') break;
23142 target = &(scripts[asdmapscripts[id]]);
23143 break;
23144 }
23145 case 8: //screen
23146 {
23147 int32_t id = assignscript_dlg[31].d1;
23148 if(id < 0 || asscreenscripts[id] == "<none>" || asscreenscripts[id].at(0) == '-') break;
23149 target = &(scripts[asscreenscripts[id]]);
23150 break;
23151 }
23152 case 9: //itemsprite
23153 {
23154 int32_t id = assignscript_dlg[37].d1;
23155 if(id < 0 || asitemspritescripts[id] == "<none>" || asitemspritescripts[id].at(0) == '-') break;
23156 target = &(scripts[asitemspritescripts[id]]);
23157 break;
23158 }
23159 case 10: //combo
23160 {
23161 int32_t id = assignscript_dlg[40].d1;
23162 if(id < 0 || ascomboscripts[id] == "<none>" || ascomboscripts[id].at(0) == '-') break;
23163 target = &(scripts[ascomboscripts[id]]);
23164 break;
23165 }
23166 case 11: //generic
23167 {
23168 int32_t id = assignscript_dlg[46].d1;
23169 if(id < 0 || asgenericscripts[id] == "<none>" || asgenericscripts[id].at(0) == '-') break;
23170 target = &(scripts[asgenericscripts[id]]);
23171 break;
23172 }
23173 case 12: //subscreen
23174 {
23175 int32_t id = assignscript_dlg[49].d1;
23176 if(id < 0 || assubscreenscripts[id] == "<none>" || assubscreenscripts[id].at(0) == '-') break;
23177 target = &(scripts[assubscreenscripts[id]]);
23178 break;
23179 }
23180 }
23181 zasm_meta* meta = target ? &target->first : nullptr;
23182 if(devpwd() && CHECK_CTRL_CMD)
23183 {
23184 string str;
23185 target->write(str, false, false, (assignscript_dlg[51].flags == D_SELECTED), true);
23186 set_al_clipboard(str);
23187 displayinfo("Clipboard Copy","Copied ZASM of selected script to clipboard");
23188 }
23189 else if(meta)
23190 showScriptInfo(meta);
23191 break;
23192 }
23193
23194 case 44:
23195 //Clear, clear slots of current type- after a confirmation.
23196 {
23197 doClearSlots(&slotflags);
23198 break;
23199 }
23200 }
23201 }
23202
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(assign_mode == 2) //Smart Assign
23203 {
23204 //For global/hero scripts, match slot names if unoccupied
23205 smart_slot_named(scripts, asglobalscripts, globalmap, global_slotnames, 1, NUMSCRIPTGLOBAL);
23206 smart_slot_named(scripts, asplayerscripts, playermap, player_slotnames, 0, NUMSCRIPTPLAYER-1);
23207 //For other scripts, assign all un-assigned scripts
23208 smart_slot_type(scripts, asffcscripts, ffcmap, NUMSCRIPTFFC-1);
23209 smart_slot_type(scripts, asitemscripts, itemmap, NUMSCRIPTITEM-1);
23210 smart_slot_type(scripts, asnpcscripts, npcmap, NUMSCRIPTGUYS-1);
23211 smart_slot_type(scripts, aslweaponscripts, lwpnmap, NUMSCRIPTWEAPONS-1);
23212 smart_slot_type(scripts, aseweaponscripts, ewpnmap, NUMSCRIPTWEAPONS-1);
23213 smart_slot_type(scripts, asscreenscripts, screenmap, NUMSCRIPTSCREEN-1);
23214 smart_slot_type(scripts, asdmapscripts, dmapmap, NUMSCRIPTSDMAP-1);
23215 smart_slot_type(scripts, asitemspritescripts, itemspritemap, NUMSCRIPTSITEMSPRITE-1);
23216 smart_slot_type(scripts, ascomboscripts, comboscriptmap, NUMSCRIPTSCOMBODATA-1);
23217 smart_slot_type(scripts, asgenericscripts, genericmap, NUMSCRIPTSGENERIC-1);
23218 smart_slot_type(scripts, assubscreenscripts, subscreenmap, NUMSCRIPTSSUBSCREEN-1);
23219 }
23220 auto_do_slots:
23221 3 doslots_log_output = (assignscript_dlg[13].flags == D_SELECTED);
23222 3 doslots_comment_output = (assignscript_dlg[51].flags == D_SELECTED);
23223 3 doslot_scripts = &scripts;
23224 //OK
23225 {
23226 3 auto start_assign_time = std::chrono::steady_clock::now();
23227
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!handle_slot_map(ffcmap, 1, ffscripts))
23228 goto exit_do_slots;
23229
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!handle_slot_map(globalmap, 0, globalscripts))
23230 goto exit_do_slots;
23231
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!handle_slot_map(itemmap, 1, itemscripts))
23232 goto exit_do_slots;
23233
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!handle_slot_map(npcmap, 1, guyscripts))
23234 goto exit_do_slots;
23235
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!handle_slot_map(lwpnmap, 1, lwpnscripts))
23236 goto exit_do_slots;
23237
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!handle_slot_map(ewpnmap, 1, ewpnscripts))
23238 goto exit_do_slots;
23239
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!handle_slot_map(playermap, 1, playerscripts))
23240 goto exit_do_slots;
23241
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!handle_slot_map(dmapmap, 1, dmapscripts))
23242 goto exit_do_slots;
23243
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!handle_slot_map(screenmap, 1, screenscripts))
23244 goto exit_do_slots;
23245
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!handle_slot_map(itemspritemap, 1, itemspritescripts))
23246 goto exit_do_slots;
23247
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!handle_slot_map(comboscriptmap, 1, comboscripts))
23248 goto exit_do_slots;
23249
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!handle_slot_map(genericmap, 1, genericscripts))
23250 goto exit_do_slots;
23251
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!handle_slot_map(subscreenmap, 1, subscreenscripts))
23252 goto exit_do_slots;
23253
23254 3 auto end_assign_time = std::chrono::steady_clock::now();
23255 3 int compile_time_ms = std::chrono::duration_cast<std::chrono::milliseconds>(end_assign_time - start_assign_time).count();
23256 3 al_trace("Assign Slots took %d ms\n", compile_time_ms);
23257 3 char buf[256] = {0};
23258 6 sprintf(buf, "ZScripts successfully loaded into script slots"
23259 3 "\nAssign Slots took %d ms", compile_time_ms);
23260 //al_trace("Module SFX datafile is %s \n",moduledata.datafiles[sfx_dat]);
23261 3 compile_finish_sample = vbound(zc_get_config("Compiler","compile_finish_sample",20),0,255);
23262 3 compile_audio_volume = vbound(zc_get_config("Compiler","compile_audio_volume",200),0,255);
23263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( compile_finish_sample > 0 )
23264 {
23265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(sfxdat)
23266 sfx_voice[compile_finish_sample]=allocate_voice((SAMPLE*)sfxdata[compile_finish_sample].dat);
23267 3 else sfx_voice[compile_finish_sample]=allocate_voice(&customsfxdata[compile_finish_sample]);
23268 3 voice_set_volume(sfx_voice[compile_finish_sample], compile_audio_volume);
23269 //zc_set_volume(255,-1);
23270 //kill_sfx();
23271 3 voice_start(sfx_voice[compile_finish_sample]);
23272 3 }
23273
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!assign_mode)
23274 InfoDialog("Slots Assigned",buf).show();
23275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( compile_finish_sample > 0 )
23276 {
23277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(sfx_voice[compile_finish_sample]!=-1)
23278 {
23279 3 deallocate_voice(sfx_voice[compile_finish_sample]);
23280 3 sfx_voice[compile_finish_sample]=-1;
23281 3 }
23282 3 }
23283 3 build_biffs_list();
23284 3 build_biitems_list();
23285 3 retval = true;
23286 3 goto exit_do_slots;
23287 }
23288 exit_do_slots:
23289 3 doslot_scripts = nullptr;
23290 3 popup_zqdialog_end();
23291 3 return retval;
23292 }
23293
23294 static char slottype_str_buf[32];
23295
23296 const char *slottype_list(int32_t index, int32_t *list_size)
23297 {
23298 if(index >= 0)
23299 {
23300 bound(index,0,num_types-1);
23301
23302 switch(index)
23303 {
23304 case type_ffc:
23305 strcpy(slottype_str_buf, "FFC");
23306 break;
23307 case type_global:
23308 strcpy(slottype_str_buf, "Global");
23309 break;
23310 case type_itemdata:
23311 strcpy(slottype_str_buf, "Item");
23312 break;
23313 case type_npc:
23314 strcpy(slottype_str_buf, "NPC");
23315 break;
23316 case type_lweapon:
23317 strcpy(slottype_str_buf, "LWeapon");
23318 break;
23319 case type_eweapon:
23320 strcpy(slottype_str_buf, "EWeapon");
23321 break;
23322 case type_hero:
23323 strcpy(slottype_str_buf, "Hero");
23324 break;
23325 case type_dmap:
23326 strcpy(slottype_str_buf, "DMap");
23327 break;
23328 case type_screen:
23329 strcpy(slottype_str_buf, "Screen");
23330 break;
23331 case type_itemsprite:
23332 strcpy(slottype_str_buf, "ItemSprite");
23333 break;
23334 case type_combo:
23335 strcpy(slottype_str_buf, "Combo");
23336 break;
23337 case type_generic:
23338 strcpy(slottype_str_buf, "Generic");
23339 break;
23340 case type_subscreen:
23341 strcpy(slottype_str_buf, "Subscreen");
23342 break;
23343 }
23344
23345 return slottype_str_buf;
23346 }
23347 *list_size = 11;
23348 return NULL;
23349 }
23350 8 static ListData slottype_sel_list(slottype_list, &font);
23351
23352 static DIALOG clearslots_dlg[] =
23353 {
23354 8 { jwin_win_proc, 0, 0, 200, 159, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Clear Slots", NULL, NULL },
23355 8 { jwin_button_proc, 35, 132, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Confirm", NULL, NULL },
23356 8 { jwin_button_proc, 104, 132, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
23357 8 { jwin_droplist_proc, 50, 28+16, 70, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &slottype_sel_list, NULL, NULL },
23358 8 { jwin_radio_proc, 40, 34+00, 81, 9, vc(14), vc(1), 0, D_SELECTED, 0, 0, (void *) "Clear Script Type:", NULL, NULL },
23359 8 { jwin_radio_proc, 40, 34+32, 81, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear Missing (--) Slots", NULL, NULL },
23360 8 { jwin_radio_proc, 40, 34+48, 81, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear Preserved (++) Slots", NULL, NULL },
23361 8 { jwin_radio_proc, 40, 34+64, 81, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear Imported (==) Slots", NULL, NULL },
23362 8 { jwin_radio_proc, 40, 34+80, 81, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear All", NULL, NULL },
23363 8 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
23364 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
23365 };
23366
23367 void doClearSlots(byte* flags)
23368 {
23369 //{ Setup
23370 clearslots_dlg[0].dp2=get_zc_font(font_lfont);
23371 clearslots_dlg[3].d1 = get_selected_tab((TABPANEL*)assignscript_dlg[1].dp); //Default to current tab's type
23372 clearslots_dlg[4].flags |= D_SELECTED;
23373 clearslots_dlg[5].flags &= ~D_SELECTED;
23374 clearslots_dlg[6].flags &= ~D_SELECTED;
23375 clearslots_dlg[7].flags &= ~D_SELECTED;
23376 clearslots_dlg[8].flags &= ~D_SELECTED;
23377 if(((*flags) & SLOTMSGFLAG_MISSING) == 0)
23378 clearslots_dlg[5].flags |= D_DISABLED;
23379 else
23380 clearslots_dlg[5].flags &= ~D_DISABLED;
23381 if(((*flags) & SLOTMSGFLAG_PRESERVED) == 0)
23382 clearslots_dlg[6].flags |= D_DISABLED;
23383 else
23384 clearslots_dlg[6].flags &= ~D_DISABLED;
23385 if(((*flags) & SLOTMSGFLAG_IMPORTED) == 0)
23386 clearslots_dlg[7].flags |= D_DISABLED;
23387 else
23388 clearslots_dlg[7].flags &= ~D_DISABLED;
23389 //}
23390
23391 large_dialog(clearslots_dlg);
23392
23393 if(do_zqdialog(clearslots_dlg,2)==1)
23394 {
23395 int32_t q = 3;
23396 while((clearslots_dlg[++q].flags & D_SELECTED) == 0);
23397 switch(q)
23398 {
23399 case 4: //Clear type
23400 {
23401 clearAllSlots(clearslots_dlg[3].d1);
23402 break;
23403 }
23404 case 5: //Clear Missing
23405 {
23406 for(int32_t q = 0; q <= 10; ++q)
23407 clearAllSlots(q,SLOTMSGFLAG_MISSING);
23408 break;
23409 }
23410 case 6: //Clear Preserved
23411 {
23412 for(int32_t q = 0; q <= 10; ++q)
23413 clearAllSlots(q,SLOTMSGFLAG_PRESERVED);
23414 break;
23415 }
23416 case 7: //Clear Imported ZASM
23417 {
23418 for(int32_t q = 0; q <= 10; ++q)
23419 clearAllSlots(q,SLOTMSGFLAG_IMPORTED);
23420 break;
23421 }
23422 case 8: //Clear ALL
23423 {
23424 for(int32_t q = 0; q <= 10; ++q)
23425 clearAllSlots(q);
23426 break;
23427 }
23428 }
23429 }
23430 }
23431
23432 static DIALOG exportzasm_dlg[] =
23433 {
23434 8 { jwin_win_proc, 0, 0, 200, 159, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Export ZASM", NULL, NULL },
23435 8 { jwin_button_proc, 35, 132, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Confirm", NULL, NULL },
23436 8 { jwin_button_proc, 104, 132, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
23437 8 { jwin_droplist_proc, 50, 28+16, 100, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &slottype_sel_list, NULL, NULL },
23438 8 { jwin_droplist_proc, 50, 28+48, 100, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
23439 8 { jwin_text_proc, 50, 28+8, 16, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Script Type:", NULL, NULL },
23440 8 { jwin_text_proc, 50, 28+40, 16, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Script Slot:", NULL, NULL },
23441 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
23442 };
23443
23444 static DIALOG importzasm_dlg[] =
23445 {
23446 8 { jwin_win_proc, 0, 0, 200, 159, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Import ZASM", NULL, NULL },
23447 8 { jwin_button_proc, 35, 132, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Confirm", NULL, NULL },
23448 8 { jwin_button_proc, 104, 132, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
23449 8 { jwin_droplist_proc, 50, 28+16, 100, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &slottype_sel_list, NULL, NULL },
23450 8 { jwin_droplist_proc, 50, 28+48, 100, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
23451 // 5
23452 8 { jwin_text_proc, 50, 28+8, 16, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Script Type:", NULL, NULL },
23453 8 { jwin_text_proc, 50, 28+40, 16, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Script Slot:", NULL, NULL },
23454 8 { jwin_text_proc, 50, 28+72, 16, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Script Name:", NULL, NULL },
23455 8 { jwin_edit_proc, 50, 28+80, 100, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 19, 0, NULL, NULL, NULL },
23456
23457 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
23458 };
23459 extern ListData itemscript_list;
23460 extern ListData itemspritescript_list;
23461 extern ListData lweaponscript_list;
23462 extern ListData npcscript_list;
23463 extern ListData eweaponscript_list;
23464 extern ListData comboscript_list;
23465
23466 static EXT_LIST zasm_extlist[] =
23467 {
23468 { (char *)"ZASM Files (*.zasm)", (char *)"zasm" },
23469 { NULL, NULL }
23470 };
23471
23472 int32_t onImportZASM()
23473 {
23474 importzasm_dlg[0].dp2 = get_zc_font(font_lfont);
23475 importzasm_dlg[4].dp = (void*)&ffscript_list;
23476 if(!getname("Import Script (.zasm)","zasm",zasm_extlist,datapath,false))
23477 {
23478 return D_O_K;
23479 }
23480 script_data *temp_slot = new script_data(ScriptType::None, 0);
23481 if(parse_script_file(&temp_slot, temppath, false) == D_CLOSE)
23482 {
23483 jwin_alert("Error","Failed to parse specified file!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
23484 delete temp_slot;
23485 return D_O_K;
23486 }
23487
23488 std::string namebuf;
23489 if(temp_slot->meta.valid()) //Found metadata
23490 {
23491 importzasm_dlg[3].d1 = getType(temp_slot->meta.script_type);
23492 namebuf = temp_slot->meta.script_name;
23493 switch(importzasm_dlg[3].d1)
23494 {
23495 default: //Shouldn't occur, but to be safe
23496 case type_ffc:
23497 importzasm_dlg[4].dp = (void*)&ffscript_sel_dlg_list;
23498 break;
23499 case type_global:
23500 importzasm_dlg[4].dp = (void*)&gscript_sel_dlg_list;
23501 break;
23502 case type_itemdata:
23503 importzasm_dlg[4].dp = (void*)&itemscript_sel_dlg_list;
23504 break;
23505 case type_npc:
23506 importzasm_dlg[4].dp = (void*)&npcscript_sel_dlg_list;
23507 break;
23508 case type_lweapon:
23509 importzasm_dlg[4].dp = (void*)&lweaponscript_sel_dlg_list;
23510 break;
23511 case type_eweapon:
23512 importzasm_dlg[4].dp = (void*)&eweaponscript_sel_dlg_list;
23513 break;
23514 case type_hero:
23515 importzasm_dlg[4].dp = (void*)&playerscript_sel_dlg_list;
23516 break;
23517 case type_dmap:
23518 importzasm_dlg[4].dp = (void*)&dmapscript_sel_dlg_list;
23519 break;
23520 case type_screen:
23521 importzasm_dlg[4].dp = (void*)&screenscript_sel_dlg_list;
23522 break;
23523 case type_itemsprite:
23524 importzasm_dlg[4].dp = (void*)&itemspritescript_sel_dlg_list;
23525 break;
23526 case type_combo:
23527 importzasm_dlg[4].dp = (void*)&comboscript_sel_dlg_list;
23528 break;
23529 }
23530 importzasm_dlg[4].d1 = 0;
23531 }
23532 else
23533 {
23534 importzasm_dlg[3].d1 = 0;
23535 importzasm_dlg[4].dp = (void*)&ffscript_list;
23536 importzasm_dlg[4].d1 = 0;
23537 }
23538 importzasm_dlg[8].dp = (void*)namebuf.c_str();
23539 bool confirmed = false;
23540 int32_t indx = 1;
23541 while(!confirmed)
23542 {
23543 large_dialog(importzasm_dlg);
23544 indx = do_zqdialog(importzasm_dlg, indx);
23545 switch(indx)
23546 {
23547 case 1: //confirm; exit dlg
23548 {
23549 if(!namebuf[0]) break; //No name?
23550 script_data **slot = NULL;
23551 script_slot_data *map = NULL;
23552 //{ Find script choice
23553 int32_t scriptInd = importzasm_dlg[4].d1;
23554 switch(importzasm_dlg[3].d1)
23555 {
23556 case type_ffc:
23557 slot = &ffscripts[scriptInd];
23558 map = &ffcmap[scriptInd];
23559 break;
23560 case type_global:
23561 slot = &globalscripts[scriptInd];
23562 map = &globalmap[scriptInd];
23563 break;
23564 case type_itemdata:
23565 slot = &itemscripts[scriptInd];
23566 map = &itemmap[scriptInd];
23567 break;
23568 case type_npc:
23569 slot = &guyscripts[scriptInd];
23570 map = &npcmap[scriptInd];
23571 break;
23572 case type_lweapon:
23573 slot = &lwpnscripts[scriptInd];
23574 map = &lwpnmap[scriptInd];
23575 break;
23576 case type_eweapon:
23577 slot = &ewpnscripts[scriptInd];
23578 map = &ewpnmap[scriptInd];
23579 break;
23580 case type_hero:
23581 slot = &playerscripts[scriptInd];
23582 map = &playermap[scriptInd];
23583 break;
23584 case type_dmap:
23585 slot = &dmapscripts[scriptInd];
23586 map = &dmapmap[scriptInd];
23587 break;
23588 case type_screen:
23589 slot = &screenscripts[scriptInd];
23590 map = &screenmap[scriptInd];
23591 break;
23592 case type_itemsprite:
23593 slot = &itemspritescripts[scriptInd];
23594 map = &itemspritemap[scriptInd];
23595 break;
23596 case type_combo:
23597 slot = &comboscripts[scriptInd];
23598 map = &comboscriptmap[scriptInd];
23599 break;
23600 case type_generic:
23601 slot = &genericscripts[scriptInd];
23602 map = &genericmap[scriptInd];
23603 break;
23604 case type_subscreen:
23605 slot = &subscreenscripts[scriptInd];
23606 map = &subscreenmap[scriptInd];
23607 break;
23608 }
23609 //}
23610 if(!slot) break; //Not found?
23611 *slot = std::move(temp_slot);
23612 map->format = SCRIPT_FORMAT_ZASM;
23613 map->updateName(namebuf);
23614 confirmed = true;
23615 break;
23616 }
23617 case 0: case 2: //Close dlg
23618 {
23619 delete temp_slot;
23620 return D_O_K;
23621 }
23622 case 3: //Type select
23623 {
23624 switch(importzasm_dlg[3].d1)
23625 {
23626 default: //Shouldn't occur, but to be safe
23627 case type_ffc:
23628 importzasm_dlg[4].dp = (void*)&ffscript_sel_dlg_list;
23629 break;
23630 case type_global:
23631 importzasm_dlg[4].dp = (void*)&gscript_sel_dlg_list;
23632 break;
23633 case type_itemdata:
23634 importzasm_dlg[4].dp = (void*)&itemscript_sel_dlg_list;
23635 break;
23636 case type_npc:
23637 importzasm_dlg[4].dp = (void*)&npcscript_sel_dlg_list;
23638 break;
23639 case type_lweapon:
23640 importzasm_dlg[4].dp = (void*)&lweaponscript_sel_dlg_list;
23641 break;
23642 case type_eweapon:
23643 importzasm_dlg[4].dp = (void*)&eweaponscript_sel_dlg_list;
23644 break;
23645 case type_hero:
23646 importzasm_dlg[4].dp = (void*)&playerscript_sel_dlg_list;
23647 break;
23648 case type_dmap:
23649 importzasm_dlg[4].dp = (void*)&dmapscript_sel_dlg_list;
23650 break;
23651 case type_screen:
23652 importzasm_dlg[4].dp = (void*)&screenscript_sel_dlg_list;
23653 break;
23654 case type_itemsprite:
23655 importzasm_dlg[4].dp = (void*)&itemspritescript_sel_dlg_list;
23656 break;
23657 case type_combo:
23658 importzasm_dlg[4].dp = (void*)&comboscript_sel_dlg_list;
23659 break;
23660 }
23661 importzasm_dlg[4].d1 = 0;
23662 break;
23663 }
23664 }
23665 }
23666 delete temp_slot;
23667 return D_O_K;
23668 }
23669
23670 5 void center_zscript_dialogs()
23671 {
23672 5 jwin_center_dialog(exportzasm_dlg);
23673 5 jwin_center_dialog(importzasm_dlg);
23674 5 jwin_center_dialog(clearslots_dlg);
23675 5 }
23676
23677 static DIALOG sfxlist_dlg[] =
23678 {
23679 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
23680 8 { jwin_win_proc, 60-12, 40, 200+24, 148, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
23681 8 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
23682 8 { jwin_abclist_proc, 72-12-4, 60+4, 176+24+8, 92+3, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, NULL, NULL, NULL },
23683 8 { jwin_button_proc, 90, 163, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Edit", NULL, NULL },
23684 8 { jwin_button_proc, 170, 163, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Done", NULL, NULL },
23685 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
23686 };
23687
23688 int32_t select_sfx(const char *prompt,int32_t index)
23689 {
23690 sfxlist_dlg[0].dp=(void *)prompt;
23691 sfxlist_dlg[0].dp2=get_zc_font(font_lfont);
23692 sfxlist_dlg[2].d1=index;
23693 sfxlist_dlg[2].dp=(void *) & sfx_list;
23694
23695 large_dialog(sfxlist_dlg);
23696
23697 int32_t ret=do_zqdialog(sfxlist_dlg,2);
23698
23699 if(ret==0||ret==4)
23700 {
23701 position_mouse_z(0);
23702 return -1;
23703 }
23704
23705 index = sfxlist_dlg[2].d1;
23706 position_mouse_z(0);
23707 return index;
23708 }
23709
23710 static DIALOG sfx_edit_dlg[] =
23711 {
23712 { jwin_win_proc, 0, 0, 200, 159, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "SFX", NULL, NULL },
23713 { jwin_button_proc, 35, 132, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
23714 { jwin_button_proc, 104, 132, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
23715 { jwin_button_proc, 35, 78, 61, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
23716 { jwin_button_proc, 35, 105, 61, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Play", NULL, NULL },
23717 { jwin_button_proc, 104, 105, 61, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Stop", NULL, NULL },
23718 { jwin_button_proc, 104, 78, 61, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Default", NULL, NULL },
23719 { jwin_edit_proc, 36, 25, 154, 16, vc(12), vc(1), 0, 0, 36, 0, NULL, NULL, NULL },
23720 { jwin_text_proc, 8, 30, 16, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Name:", NULL, NULL },
23721 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
23722 { jwin_button_proc, 70, 51, 61, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Save", NULL, NULL },
23723 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
23724 };
23725
23726 /*****************/
23727 /***** SFX *****/
23728 /*****************/
23729
23730 // array of voices, one for each sfx sample in the data file
23731 // 0+ = voice #
23732 // -1 = voice not allocated
23733 int32_t sfx_voice[WAV_COUNT];
23734
23735 void Z_init_sound()
23736 {
23737 for(int32_t i=0; i<WAV_COUNT; i++)
23738 sfx_voice[i]=-1;
23739
23740 // master_volume(digi_volume,midi_volume);
23741 }
23742
23743 // returns number of voices currently allocated
23744 int32_t sfx_count()
23745 {
23746 int32_t c=0;
23747
23748 for(int32_t i=0; i<WAV_COUNT; i++)
23749 if(sfx_voice[i]!=-1)
23750 ++c;
23751
23752 return c;
23753 }
23754
23755 // clean up finished samples
23756 void sfx_cleanup()
23757 {
23758 for(int32_t i=0; i<WAV_COUNT; i++)
23759 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
23760 {
23761 deallocate_voice(sfx_voice[i]);
23762 sfx_voice[i]=-1;
23763 }
23764 }
23765
23766 // allocates a voice for the sample "wav_index" (index into zelda.dat)
23767 // if a voice is already allocated (and/or playing), then it just returns true
23768 // Returns true: voice is allocated
23769 // false: unsuccessful
23770 SAMPLE templist[WAV_COUNT];
23771
23772 bool sfx_init(int32_t index)
23773 {
23774 // check index
23775 if(index<1 || index>=WAV_COUNT)
23776 return false;
23777
23778 if(sfx_voice[index]==-1)
23779 {
23780 sfx_voice[index]=allocate_voice(&templist[index]);
23781 }
23782
23783 return sfx_voice[index] != -1;
23784 }
23785
23786 // plays an sfx sample
23787 void sfx(int32_t index,int32_t pan,bool loop,bool restart,int32_t vol,int32_t freq)
23788 {
23789 if(!sfx_init(index))
23790 return;
23791
23792 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
23793 voice_set_pan(sfx_voice[index],pan);
23794
23795 int32_t pos = voice_get_position(sfx_voice[index]);
23796
23797 if(restart) voice_set_position(sfx_voice[index],0);
23798
23799 if(pos<=0)
23800 voice_start(sfx_voice[index]);
23801 }
23802
23803 // start it (in loop mode) if it's not already playing,
23804 // otherwise just leave it in its current position
23805 void cont_sfx(int32_t index)
23806 {
23807 if(!sfx_init(index))
23808 return;
23809
23810 if(voice_get_position(sfx_voice[index])<=0)
23811 {
23812 voice_set_position(sfx_voice[index],0);
23813 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
23814 voice_start(sfx_voice[index]);
23815 }
23816 }
23817
23818 // adjust parameters while playing
23819 void adjust_sfx(int32_t index,int32_t pan,bool loop)
23820 {
23821 if(index<0 || index>=WAV_COUNT || sfx_voice[index]==-1)
23822 return;
23823
23824 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
23825 voice_set_pan(sfx_voice[index],pan);
23826 }
23827
23828 // pauses a voice
23829 void pause_sfx(int32_t index)
23830 {
23831 if(index>=0 && index<WAV_COUNT && sfx_voice[index]!=-1)
23832 voice_stop(sfx_voice[index]);
23833 }
23834
23835 // resumes a voice
23836 void resume_sfx(int32_t index)
23837 {
23838 if(index>=0 && index<WAV_COUNT && sfx_voice[index]!=-1)
23839 voice_start(sfx_voice[index]);
23840 }
23841
23842 // pauses all active voices
23843 void pause_all_sfx()
23844 {
23845 for(int32_t i=0; i<WAV_COUNT; i++)
23846 if(sfx_voice[i]!=-1)
23847 voice_stop(sfx_voice[i]);
23848 }
23849
23850 // resumes all paused voices
23851 void resume_all_sfx()
23852 {
23853 for(int32_t i=0; i<WAV_COUNT; i++)
23854 if(sfx_voice[i]!=-1)
23855 voice_start(sfx_voice[i]);
23856 }
23857
23858 // stops an sfx and deallocates the voice
23859 void stop_sfx(int32_t index)
23860 {
23861 if(index<0 || index>=WAV_COUNT)
23862 return;
23863
23864 if(sfx_voice[index]!=-1)
23865 {
23866 deallocate_voice(sfx_voice[index]);
23867 sfx_voice[index]=-1;
23868 }
23869 }
23870
23871 void kill_sfx()
23872 {
23873 for(int32_t i=0; i<WAV_COUNT; i++)
23874 if(sfx_voice[i]!=-1)
23875 {
23876 deallocate_voice(sfx_voice[i]);
23877 sfx_voice[i]=-1;
23878 }
23879 }
23880
23881 int32_t pan(int32_t x)
23882 {
23883 return 128;
23884 /*switch(pan_style)
23885 {
23886 case 0: return 128;
23887 case 1: return vbound((x>>1)+68,0,255);
23888 case 2: return vbound(((x*3)>>2)+36,0,255);
23889 }
23890 return vbound(x,0,255);*/
23891 }
23892
23893
23894 void change_sfx(SAMPLE *sfx1, SAMPLE *sfx2)
23895 {
23896 sfx1->bits = sfx2->bits;
23897 sfx1->stereo = sfx2->stereo;
23898 sfx1->freq = sfx2->freq;
23899 sfx1->priority = sfx2->priority;
23900 sfx1->len = sfx2->len;
23901 sfx1->loop_start = sfx2->loop_start;
23902 sfx1->loop_end = sfx2->loop_end;
23903 sfx1->param = sfx2->param;
23904
23905 if(sfx1->data != NULL)
23906 {
23907 free(sfx1->data);
23908 }
23909
23910 if(sfx2->data == NULL)
23911 sfx1->data = NULL;
23912 else
23913 {
23914 // When quests are saved and loaded, data is written in words.
23915 // If the last byte is dropped, it'll cause the sound to end with
23916 // a click. It could simply be extended and padded with 0, but
23917 // that causes compatibility issues... So we'll cut off
23918 // the last byte and decrease the length.
23919
23920 int32_t len = (sfx1->bits==8?1:2)*(sfx1->stereo == 0 ? 1 : 2)*sfx1->len;
23921
23922 while(len%sizeof(word))
23923 {
23924 // sizeof(word) should be 2, so this doesn't really need
23925 // to be a loop, but what the heck.
23926 sfx1->len--;
23927 len = (sfx1->bits==8?1:2)*(sfx1->stereo == 0 ? 1 : 2)*sfx1->len;
23928 }
23929
23930 sfx1->data = malloc(len);
23931 memcpy(sfx1->data, sfx2->data, len);
23932 }
23933 }
23934
23935 bool confirmBox(const char *m1, const char *m2, const char *m3)
23936 {
23937 if(!m3)
23938 {
23939 if(!m2) m2 = "Are you sure?";
23940 else m3 = "Are you sure?";
23941 }
23942 return jwin_alert("Confirmation", m1, m2, m3, "Yes", "No", 'y', 'n', get_zc_font(font_lfont)) == 1;
23943 }
23944
23945 int32_t onSelectSFX()
23946 {
23947 int32_t index = select_sfx("Select SFX",0);
23948
23949 while(index >= 0)
23950 {
23951 if(index)
23952 onEditSFX(index);
23953
23954 index = select_sfx("Select SFX",index);
23955 }
23956
23957 refresh(rMAP+rCOMBOS);
23958 return D_O_K;
23959 }
23960
23961 bool saveWAV(int32_t slot, const char *filename)
23962 {
23963 if (slot < 1 || slot >= 511 )
23964 return false;
23965
23966 if (customsfxdata[slot].data == NULL)
23967 return false;
23968
23969 std::ofstream ofs(filename, std::ios::binary);
23970 if (!ofs)
23971 return false;
23972 ofs.write("RIFF",4);
23973 uint32_t samplerate = customsfxdata[slot].freq;
23974 uint16_t channels = customsfxdata[slot].stereo ? 2 : 1;
23975 uint32_t datalen = customsfxdata[slot].len*channels*customsfxdata[slot].bits / 8;
23976 uint32_t size = 36 + datalen;
23977 ofs.write((char *)&size, 4);
23978 ofs.write("WAVE", 4);
23979 ofs.write("fmt ", 4);
23980 uint32_t fmtlen = 16;
23981 ofs.write((char *)&fmtlen, 4);
23982 uint16_t type = 1;
23983 ofs.write((char *)&type, 2);
23984 ofs.write((char *)&channels, 2);
23985 ofs.write((char *)&samplerate, 4);
23986 uint32_t bytespersec = samplerate*channels*customsfxdata[slot].bits / 8;
23987 ofs.write((char *)&bytespersec, 4);
23988 uint16_t blockalign = channels*customsfxdata[slot].bits / 8;
23989 ofs.write((char *)&blockalign, 2);
23990 uint16_t bitspersample = customsfxdata[slot].bits;
23991 ofs.write((char *)&bitspersample, 2);
23992 ofs.write("data", 4);
23993 ofs.write((char *)&datalen, 4);
23994 if (bitspersample == 8)
23995 {
23996 for (int32_t i = 0; i < (int32_t)customsfxdata[slot].len*channels; i++)
23997 {
23998 char data = ((char *)customsfxdata[slot].data)[i];
23999 data ^= 0x80;
24000 ofs.write(&data, 1);
24001 }
24002 }
24003 else if (bitspersample == 16)
24004 {
24005 for (int32_t i = 0; i < (int32_t)customsfxdata[slot].len*channels; i++)
24006 {
24007 uint16_t data = ((uint16_t *)customsfxdata[slot].data)[i];
24008 data ^= 0x8000;
24009 ofs.write((char *)&data, 2);
24010 }
24011 }
24012 else
24013 return false;
24014 return !!ofs;
24015 }
24016
24017 int32_t onEditSFX(int32_t index)
24018 {
24019 kill_sfx();
24020 zc_stop_midi();
24021 zc_set_volume(255,-1);
24022 int32_t ret;
24023 sfx_edit_dlg[0].dp2=get_zc_font(font_lfont);
24024 uint8_t tempflag;
24025 tempflag = get_bit(customsfxflag,index-1);
24026 change_sfx(&templist[index], &customsfxdata[index]);
24027
24028 char sfxnumstr[50];
24029 sprintf(sfxnumstr,"SFX %d: %s", index, sfx_string[index]);
24030 sfx_edit_dlg[0].dp = sfxnumstr;
24031
24032 char name[36];
24033 strcpy(name,sfx_string[index]);
24034 sfx_edit_dlg[7].dp = name;
24035
24036 large_dialog(sfx_edit_dlg);
24037
24038 do
24039 {
24040 ret=do_zqdialog(sfx_edit_dlg,1);
24041
24042 switch(ret)
24043 {
24044 case 1:
24045 saved= false;
24046 kill_sfx();
24047 change_sfx(&customsfxdata[index],&templist[index]);
24048 set_bit(customsfxflag,index-1,tempflag);
24049 strcpy(sfx_string[index], name);
24050
24051 case 2:
24052 case 0:
24053 // Fall Through
24054 kill_sfx();
24055
24056 for(int32_t i=1; i<WAV_COUNT; i++)
24057 {
24058 if(templist[i].data != NULL)
24059 {
24060 free(templist[i].data);
24061 templist[i].data = NULL;
24062 }
24063 }
24064
24065 break;
24066
24067 case 3:
24068 if(getname("Open .WAV file", "wav", NULL,temppath, true))
24069 {
24070 SAMPLE * temp_sample;
24071
24072 if((temp_sample = load_wav(temppath))==NULL)
24073 {
24074 jwin_alert("Error","Could not open file",temppath,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
24075 }
24076 else
24077 {
24078 char sfxtitle[36];
24079 char *t = get_filename(temppath);
24080 int32_t j;
24081
24082 for(j=0; j<35 && t[j]!=0 && t[j]!='.'; j++)
24083 {
24084 sfxtitle[j]=t[j];
24085 }
24086
24087 sfxtitle[j]=0;
24088 strcpy(name,sfxtitle);
24089 kill_sfx();
24090 change_sfx(&templist[index], temp_sample);
24091 destroy_sample(temp_sample);
24092 tempflag = 1;
24093 }
24094 }
24095
24096 break;
24097
24098 case 4:
24099 {
24100 kill_sfx();
24101
24102 if(templist[index].data != NULL)
24103 {
24104 sfx(index, 128, false,true);
24105 }
24106 }
24107 break;
24108
24109 case 5:
24110 kill_sfx();
24111 break;
24112
24113 case 6:
24114 kill_sfx();
24115
24116 if(index < WAV_COUNT)
24117 {
24118 SAMPLE *temp_sample = (SAMPLE *)sfxdata[zc_min(index,Z35)].dat;
24119 change_sfx(&templist[index], temp_sample);
24120 tempflag = 1; //now count as custom sfx
24121 sprintf(name,"s%03d", index);
24122
24123 if(index <Z35)
24124 {
24125 strcpy(name, old_sfx_string[index-1]);
24126 }
24127 }
24128
24129 break;
24130
24131
24132 case 10:
24133 {
24134 temppath[0]=0;//memset(temppath, 0, sizeof(temppath));
24135 char tempname[36];
24136 strcpy(tempname,sfx_string[index]);
24137 //change spaces to dashes for f/s safety
24138 for ( int32_t q = 0; q < 36; ++q )
24139 {
24140 if(tempname[q] == 32 || tempname[q] == 47 || tempname[q] == 92 ) //SPACE, Bslash, Fslash
24141 tempname[q] = 45; //becomes hyphen
24142 }
24143
24144 tempname[35] = 0;
24145
24146 strcpy(temppath,tempname);
24147
24148 //zprint2("temppath is: %s\n", temppath);
24149 //zprint2("tempname is: %s\n", tempname);
24150 //save
24151 if(templist[index].data != NULL)
24152 {
24153 if (getname("Save .WAV file", "wav", NULL, temppath, true))
24154 {
24155 if(!saveWAV(index, temppath))
24156 {
24157 jwin_alert("Error!", "Could not write file", temppath, NULL, "OK", NULL, 13, 27, get_zc_font(font_lfont));
24158 }
24159 else
24160 {
24161 jwin_alert("Success!", "Saved WAV file", temppath, NULL, "OK", NULL, 13, 27, get_zc_font(font_lfont));
24162 }
24163 }
24164 }
24165 else
24166 {
24167 jwin_alert("Error!", "Cannot save an enpty slot!", NULL, NULL, "OK", NULL, 13, 27, get_zc_font(font_lfont));
24168 }
24169 break;
24170 }
24171 }
24172 }
24173 while(ret>2);
24174
24175 return D_O_K;
24176 }
24177
24178
24179 static DIALOG mapstyles_dlg[] =
24180 {
24181 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
24182 { jwin_win_proc, 0, 0, 307, 186, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Map Styles", NULL, NULL },
24183 { jwin_ctext_proc, 24, 34, 36, 36, 0, 0, 0, 0, 0, 0, (void *) "Frame", NULL, NULL }, //frame
24184 { jwin_ctext_proc, 68, 26, 20, 20, 0, 0, 0, 0, 0, 0, (void *) "Triforce", NULL, NULL }, //triforce fragment
24185 { jwin_ctext_proc, 68, 34, 20, 20, 0, 0, 0, 0, 0, 0, (void *) "Fragment", NULL, NULL }, //triforce fragment
24186 { jwin_ctext_proc, 152, 26, 100, 52, 0, 0, 0, 0, 0, 0, (void *) "Triforce Frame", NULL, NULL }, //triforce frame
24187 { jwin_ctext_proc, 152, 34, 100, 52, 0, 0, 0, 0, 0, 0, (void *) "(Normal or Double Sized)", NULL, NULL }, //triforce frame
24188 { jwin_ctext_proc, 260, 34, 84, 52, 0, 0, 0, 0, 0, 0, (void *) "Overworld Map", NULL, NULL }, //overworld map
24189 { jwin_ctext_proc, 24, 82, 20, 20, 0, 0, 0, 0, 0, 0, (void *) "Heart", NULL, NULL }, //heart container piece
24190 { jwin_ctext_proc, 24, 90, 20, 20, 0, 0, 0, 0, 0, 0, (void *) "Container", NULL, NULL }, //heart container piece
24191 { jwin_ctext_proc, 24, 98, 20, 20, 0, 0, 0, 0, 0, 0, (void *) "Piece", NULL, NULL }, //heart container piece
24192 { jwin_ctext_proc, 260, 98, 84, 52, 0, 0, 0, 0, 0, 0, (void *) "Dungeon Map", NULL, NULL }, //dungeon map
24193 // 11
24194 { jwin_frame_proc, 6, 42, 36, 36, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL }, //frame
24195 // { jwin_frame_proc, 50, 42, 36, 52, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL }, //bs triforce fragment
24196 { jwin_frame_proc, 58, 42, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL }, //normal triforce fragment
24197 // { jwin_frame_proc, 94, 42, 116, 116, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL }, //bs triforce frame
24198 { jwin_frame_proc, 102, 42, 100, 52, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL }, //normaltriforce frame
24199 { jwin_frame_proc, 218, 42, 84, 52, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL }, //overworld map
24200 { jwin_frame_proc, 14, 106, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL }, //heart container piece
24201 { jwin_frame_proc, 218, 106, 84, 52, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL }, //dungeon map
24202 // 17
24203 { d_maptile_proc, 8, 44, 32, 32, 0, 0, 0, 0, 0, 0, NULL, (void*)1, NULL }, //frame
24204 // { d_maptile_proc, 52, 44, 32, 48, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }, //bs triforce fragment
24205 { d_maptile_proc, 60, 44, 16, 16, 0, 0, 0, 0, 0, 0, NULL, (void*)1, NULL }, //normal triforce fragment
24206 // { d_maptile_proc, 96, 44, 112, 112, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }, //bs triforce frame
24207 { d_maptile_proc, 104, 44, 96, 48, 0, 0, 0, 0, 0, 0, NULL, (void*)1, NULL }, //normal triforce frame
24208 { d_maptile_proc, 220, 44, 80, 48, 0, 0, 0, 0, 0, 0, NULL, (void*)1, NULL }, //overworld map
24209 { d_maptile_proc, 16, 108, 16, 16, 0, 0, 0, 0, 0, 0, NULL, (void*)1, NULL }, //heart container piece
24210 { d_maptile_proc, 220, 108, 80, 48, 0, 0, 0, 0, 0, 0, NULL, (void*)1, NULL }, //dungeon map
24211 // 23
24212 { jwin_button_proc, 83, 162, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
24213 { jwin_button_proc, 163, 162, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
24214 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
24215 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
24216 };
24217
24218 int32_t onMapStyles()
24219 {
24220 if(mapstyles_dlg[0].d1<1)
24221 {
24222 mapstyles_dlg[12].x=mapstyles_dlg[0].x+50;
24223 mapstyles_dlg[12].w=36;
24224 mapstyles_dlg[12].h=52;
24225 mapstyles_dlg[13].x=mapstyles_dlg[0].x+94;
24226 mapstyles_dlg[13].w=116;
24227 mapstyles_dlg[13].h=116;
24228 mapstyles_dlg[18].x=mapstyles_dlg[12].x+2;
24229 mapstyles_dlg[18].w=mapstyles_dlg[12].w-4;
24230 mapstyles_dlg[18].h=mapstyles_dlg[12].h-4;
24231 mapstyles_dlg[19].x=mapstyles_dlg[13].x+2;
24232 mapstyles_dlg[19].w=mapstyles_dlg[13].w-4;
24233 mapstyles_dlg[19].h=mapstyles_dlg[13].h-4;
24234 }
24235
24236 mapstyles_dlg[0].dp2 = get_zc_font(font_lfont);
24237 //al_trace("onMapStyles() read blueframe_tile as: %d\n", QMisc.colors.blueframe_tile);
24238 mapstyles_dlg[17].d1 = QMisc.colors.blueframe_tile;
24239 mapstyles_dlg[17].fg = QMisc.colors.blueframe_cset;
24240 //al_trace("onMapStyles() read triforce_tile as: %d\n", QMisc.colors.triforce_tile);
24241 mapstyles_dlg[18].d1 = QMisc.colors.triforce_tile;
24242 mapstyles_dlg[18].fg = QMisc.colors.triforce_cset;
24243 //al_trace("onMapStyles() read triframe_tile as: %d\n", QMisc.colors.triframe_tile);
24244 mapstyles_dlg[19].d1 = QMisc.colors.triframe_tile;
24245 mapstyles_dlg[19].fg = QMisc.colors.triframe_cset;
24246 //al_trace("onMapStyles() read overworld_map_tile as: %d\n", QMisc.colors.overworld_map_tile);
24247 mapstyles_dlg[20].d1 = QMisc.colors.overworld_map_tile;
24248 mapstyles_dlg[20].fg = QMisc.colors.overworld_map_cset;
24249 //al_trace("onMapStyles() read HCpieces_tile as: %d\n", QMisc.colors.HCpieces_tile);
24250 mapstyles_dlg[21].d1 = QMisc.colors.HCpieces_tile;
24251 mapstyles_dlg[21].fg = QMisc.colors.HCpieces_cset;
24252 //al_trace("onMapStyles() read dungeon_map_tile as: %d\n", QMisc.colors.dungeon_map_tile);
24253 mapstyles_dlg[22].d1 = QMisc.colors.dungeon_map_tile;
24254 mapstyles_dlg[22].fg = QMisc.colors.dungeon_map_cset;
24255
24256 large_dialog(mapstyles_dlg,2);
24257
24258 go();
24259 int32_t ret = do_zqdialog(mapstyles_dlg,-1);
24260 comeback();
24261
24262 if(ret==23)
24263 {
24264 QMisc.colors.blueframe_tile = mapstyles_dlg[17].d1;
24265 QMisc.colors.blueframe_cset = mapstyles_dlg[17].fg;
24266 QMisc.colors.triforce_tile = mapstyles_dlg[18].d1;
24267 QMisc.colors.triforce_cset = mapstyles_dlg[18].fg;
24268 QMisc.colors.triframe_tile = mapstyles_dlg[19].d1;
24269 QMisc.colors.triframe_cset = mapstyles_dlg[19].fg;
24270 QMisc.colors.overworld_map_tile = mapstyles_dlg[20].d1;
24271 QMisc.colors.overworld_map_cset = mapstyles_dlg[20].fg;
24272 QMisc.colors.HCpieces_tile = mapstyles_dlg[21].d1;
24273 QMisc.colors.HCpieces_cset = mapstyles_dlg[21].fg;
24274 QMisc.colors.dungeon_map_tile = mapstyles_dlg[22].d1;
24275 QMisc.colors.dungeon_map_cset = mapstyles_dlg[22].fg;
24276 saved=false;
24277 }
24278
24279 return D_O_K;
24280 }
24281
24282 int32_t d_misccolors_old_proc(int32_t msg,DIALOG *d,int32_t c)
24283 {
24284 //these are here to bypass compiler warnings about unused arguments
24285 c=c;
24286
24287 if(msg==MSG_DRAW)
24288 {
24289 textout_ex(screen,font,"0123456789ABCDEF",d->x+8,d->y,d->fg,d->bg);
24290 textout_ex(screen,font,"0",d->x,d->y+8,d->fg,d->bg);
24291 textout_ex(screen,font,"1",d->x,d->y+16,d->fg,d->bg);
24292 textout_ex(screen,font,"5",d->x,d->y+24,d->fg,d->bg);
24293
24294 for(int32_t i=0; i<32; i++)
24295 {
24296 int32_t px2 = d->x+((i&15)<<3)+8;
24297 int32_t py2 = d->y+((i>>4)<<3)+8;
24298 rectfill(screen,px2,py2,px2+7,py2+7,i);
24299 }
24300
24301 for(int32_t i=0; i<16; i++)
24302 {
24303 int32_t px2 = d->x+(i<<3)+8;
24304 rectfill(screen,px2,d->y+24,px2+7,d->y+31,i+80);
24305 }
24306 }
24307
24308 return D_O_K;
24309 }
24310
24311 int32_t hexclicked=-1;
24312
24313 int32_t d_misccolors_hexedit_proc(int32_t msg,DIALOG *d,int32_t c)
24314 {
24315 switch(msg)
24316 {
24317 case MSG_GOTFOCUS:
24318 hexclicked=((int32_t)(size_t)(d->dp3))+20;
24319 break;
24320
24321 case MSG_LOSTFOCUS:
24322 hexclicked=-1;
24323 break;
24324 }
24325
24326 return d_hexedit_proc(msg,d,c);
24327 }
24328
24329
24330 int32_t d_misccolors_proc(int32_t msg,DIALOG *d,int32_t c);
24331
24332 static int32_t misccolor1_list[] =
24333 {
24334 // dialog control number
24335 4, 5, 6, 7, 8, 20, 21, 22, 23, 24, 36, 37, 38, 39, 40, -1
24336 };
24337
24338 static int32_t misccolor2_list[] =
24339 {
24340 // dialog control number
24341 9, 10, 11, 12, 13, 25, 26, 27, 28, 29, 41, 42, 43, 44, 45, -1
24342 };
24343
24344 static int32_t misccolor3_list[] =
24345 {
24346 // dialog control number
24347 14, 15, 16, 17, 18, 30, 31, 32, 33, 34, 46, 47, 48, 49, 50, -1
24348 };
24349
24350 static int32_t misccolor4_list[] =
24351 {
24352 19, 35, 51, 54, 55, 56, -1
24353 };
24354
24355 static TABPANEL misccolor_tabs[] =
24356 {
24357 // (text)
24358 { (char *)"1", D_SELECTED, misccolor1_list, 0, NULL },
24359 { (char *)"2", 0, misccolor2_list, 0, NULL },
24360 { (char *)"3", 0, misccolor3_list, 0, NULL },
24361 { (char *)"4", 0, misccolor4_list, 0, NULL },
24362 { NULL, 0, NULL, 0, NULL }
24363 };
24364
24365 int32_t d_misccolors_tab_proc(int32_t msg,DIALOG *d,int32_t c);
24366
24367 static DIALOG misccolors_dlg[] =
24368 {
24369 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
24370 8 { jwin_win_proc, 2, 21, 316, 197-23, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Misc Colors", NULL, NULL },
24371 // { jwin_frame_proc, 98-84+1+2, 52+8-6+4, 132, 100, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
24372 8 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
24373 8 { d_misccolors_proc, 92-84+1+2, 44+8-6+4, 128+8, 96+8, vc(9), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
24374 //3
24375 8 { d_misccolors_tab_proc, 150+14-2+10-15, 60-14, 150-10+15, 144-20-10, jwin_pal[jcBOXFG], jwin_pal[jcBOX], 0, 0, 0, 0, (void *) misccolor_tabs, NULL, (void *)misccolors_dlg },
24376 //4
24377 8 { jwin_text_proc, 215-25-12-15, 76-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Text:", NULL, NULL },
24378 8 { jwin_text_proc, 215-25-12-15, 94-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Caption:", NULL, NULL },
24379 8 { jwin_text_proc, 215-25-12-15, 112-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Overworld Minmap:", NULL, NULL },
24380 8 { jwin_text_proc, 215-25-12-15, 130-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Minimap Background:", NULL, NULL },
24381 8 { jwin_text_proc, 215-25-12-15, 148-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Minimap Foreground 1:", NULL, NULL },
24382 8 { jwin_text_proc, 215-25-12-15, 76-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Minimap Foreground 2:", NULL, NULL },
24383 8 { jwin_text_proc, 215-25-12-15, 94-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "BS Minimap Dark:", NULL, NULL },
24384 8 { jwin_text_proc, 215-25-12-15, 112-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "BS Minimap Goal:", NULL, NULL },
24385 8 { jwin_text_proc, 215-25-12-15, 130-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Compass Mark (Light):", NULL, NULL },
24386 8 { jwin_text_proc, 215-25-12-15, 148-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Compass Mark (Dark):", NULL, NULL },
24387 8 { jwin_text_proc, 215-25-12-15, 76-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Subscreen Background:", NULL, NULL },
24388 8 { jwin_text_proc, 215-25-12-15, 94-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Subscreen Shadow:", NULL, NULL },
24389 8 { jwin_text_proc, 215-25-12-15, 112-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Triforce Frame:", NULL, NULL },
24390 8 { jwin_text_proc, 215-25-12-15, 130-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Big Map Background:", NULL, NULL },
24391 8 { jwin_text_proc, 215-25-12-15, 148-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Big Map Foreground:", NULL, NULL },
24392 8 { jwin_text_proc, 215-25-12-15, 76-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Player's Position:", NULL, NULL },
24393
24394 //20
24395 8 { d_misccolors_hexedit_proc, 294-25+14+2, 76-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)0, },
24396 8 { d_misccolors_hexedit_proc, 294-25+14+2, 94-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)1, },
24397 8 { d_misccolors_hexedit_proc, 294-25+14+2, 112-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)2, },
24398 8 { d_misccolors_hexedit_proc, 294-25+14+2, 130-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)3, },
24399 8 { d_misccolors_hexedit_proc, 294-25+14+2, 148-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)4, },
24400 8 { d_misccolors_hexedit_proc, 294-25+14+2, 76-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)5, },
24401 8 { d_misccolors_hexedit_proc, 294-25+14+2, 94-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)6, },
24402 8 { d_misccolors_hexedit_proc, 294-25+14+2, 112-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)7, },
24403 8 { d_misccolors_hexedit_proc, 294-25+14+2, 130-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)8, },
24404 8 { d_misccolors_hexedit_proc, 294-25+14+2, 148-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)9, },
24405 8 { d_misccolors_hexedit_proc, 294-25+14+2, 76-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)10, },
24406 8 { d_misccolors_hexedit_proc, 294-25+14+2, 94-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)11, },
24407 8 { d_misccolors_hexedit_proc, 294-25+14+2, 112-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)12, },
24408 8 { d_misccolors_hexedit_proc, 294-25+14+2, 130-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)13, },
24409 8 { d_misccolors_hexedit_proc, 294-25+14+2, 148-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)14, },
24410 8 { d_misccolors_hexedit_proc, 294-25+14+2, 76-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)15, },
24411
24412 //36
24413 8 { jwin_text_proc, 283-25+14+2, 76-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24414 8 { jwin_text_proc, 283-25+14+2, 94-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24415 8 { jwin_text_proc, 283-25+14+2, 112-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24416 8 { jwin_text_proc, 283-25+14+2, 130-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24417 8 { jwin_text_proc, 283-25+14+2, 148-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24418 8 { jwin_text_proc, 283-25+14+2, 76-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24419 8 { jwin_text_proc, 283-25+14+2, 94-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24420 8 { jwin_text_proc, 283-25+14+2, 112-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24421 8 { jwin_text_proc, 283-25+14+2, 130-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24422 8 { jwin_text_proc, 283-25+14+2, 148-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24423 8 { jwin_text_proc, 283-25+14+2, 76-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24424 8 { jwin_text_proc, 283-25+14+2, 94-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24425 8 { jwin_text_proc, 283-25+14+2, 112-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24426 8 { jwin_text_proc, 283-25+14+2, 130-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24427 8 { jwin_text_proc, 283-25+14+2, 148-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24428 8 { jwin_text_proc, 283-25+14+2, 76-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24429
24430 //52
24431 8 { jwin_button_proc, 90, 190-20, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
24432 8 { jwin_button_proc, 170, 190-20, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
24433 8 { jwin_text_proc, 215-25-12-15, 94-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Message Text:", NULL, NULL },
24434 8 { d_misccolors_hexedit_proc, 294-25+14+2, 94-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)35, },
24435 8 { jwin_text_proc, 283-25+14+2, 94-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24436 8 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
24437 };
24438
24439 int32_t d_misccolors_tab_proc(int32_t msg,DIALOG *d,int32_t c)
24440 {
24441
24442 switch(msg)
24443 {
24444 case MSG_WANTFOCUS:
24445 return D_WANTFOCUS;
24446 break;
24447 }
24448
24449 return jwin_tab_proc(msg,d,c);
24450 }
24451
24452
24453 int32_t d_misccolors_proc(int32_t msg,DIALOG *d,int32_t c)
24454 {
24455 //these are here to bypass compiler warnings about unused arguments
24456 c=c;
24457 int32_t mul=12;
24458
24459 switch(msg)
24460 {
24461 case MSG_CLICK:
24462 if(hexclicked!=-1)
24463 {
24464 int32_t color_col=vbound(((gui_mouse_x()-d->x-8)/mul),0,15);
24465 int32_t color_row=vbound(((gui_mouse_y()-d->y-10)/mul),0,11);
24466 sprintf((char*)misccolors_dlg[hexclicked].dp,"%X%X",color_row,color_col);
24467 object_message(misccolors_dlg+hexclicked,MSG_DRAW,0);
24468 }
24469
24470 break;
24471
24472 case MSG_DRAW:
24473 for(int32_t i=0; i<10; i++)
24474 {
24475 textprintf_centre_ex(screen,font,d->x+8+4+(i*mul),d->y,jwin_pal[jcBOXFG],jwin_pal[jcBOX], "%d", i);
24476 }
24477
24478 for(int32_t i=0; i<6; i++)
24479 {
24480 textprintf_centre_ex(screen,font,d->x+8+4+((10+i)*mul),d->y,jwin_pal[jcBOXFG],jwin_pal[jcBOX], "%c", i+'A');
24481 }
24482
24483 for(int32_t i=0; i<10; i++)
24484 {
24485 textprintf_right_ex(screen,font,d->x+6,d->y+(i*mul)+10,jwin_pal[jcBOXFG],jwin_pal[jcBOX], "%d", i);
24486 }
24487
24488 for(int32_t i=0; i<2; i++)
24489 {
24490 textprintf_right_ex(screen,font,d->x+6,d->y+((i+10)*mul)+10,jwin_pal[jcBOXFG],jwin_pal[jcBOX], "%c", i+'A');
24491 }
24492
24493 jwin_draw_frame(screen,d->x+6,d->y+8,int32_t(132*1.5)-2,int32_t(100*1.5)-2,FR_DEEP);
24494
24495 for(int32_t i=0; i<192; i++)
24496 {
24497 int32_t px2 = d->x+int32_t(((i&15)<<3)*1.5)+8;
24498 int32_t py2 = d->y+int32_t(((i>>4)<<3)*1.5)+8+2;
24499 rectfill(screen,px2,py2,px2+(mul-1),py2+(mul-1),i);
24500 }
24501
24502 break;
24503 }
24504
24505 return D_O_K;
24506 }
24507
24508
24509 int32_t onMiscColors()
24510 {
24511 char buf[17][3];
24512 byte *si = &(QMisc.colors.text);
24513 misccolors_dlg[0].dp2=get_zc_font(font_lfont);
24514
24515 for(int32_t i=0; i<16; i++)
24516 {
24517 sprintf(buf[i],"%02X",*(si++));
24518 sprintf(buf[16], "%02X", QMisc.colors.msgtext);
24519 misccolors_dlg[i+20].dp = buf[i];
24520 misccolors_dlg[55].dp = buf[16];
24521 }
24522
24523 large_dialog(misccolors_dlg);
24524
24525 if(do_zqdialog(misccolors_dlg,0)==52)
24526 {
24527 saved=false;
24528 si = &(QMisc.colors.text);
24529
24530 for(int32_t i=0; i<16; i++)
24531 {
24532 *si = zc_xtoi(buf[i]);
24533 ++si;
24534 }
24535
24536 QMisc.colors.msgtext = zc_xtoi(buf[16]);
24537 }
24538
24539 return D_O_K;
24540 }
24541
24542 // **** Palette cycling ****
24543
24544 static int32_t palclk[3];
24545 static int32_t palpos[3];
24546
24547 23 void reset_pal_cycling()
24548 {
24549
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 23 times.
92 for(int32_t i=0; i<3; i++)
24550 69 palclk[i]=palpos[i]=0;
24551 23 }
24552
24553 void cycle_palette()
24554 {
24555 if(!get_qr(qr_FADE))
24556 return;
24557
24558 int32_t level = Map.CurrScr()->color;
24559 bool refreshpal = false;
24560
24561 for(int32_t i=0; i<3; i++)
24562 {
24563 palcycle c = QMisc.cycles[level][i];
24564
24565 if(c.count&0xF0)
24566 {
24567 if(++palclk[i] >= c.speed)
24568 {
24569 palclk[i]=0;
24570
24571 if(++palpos[i] >= (c.count>>4))
24572 palpos[i]=0;
24573
24574 byte *si = colordata + CSET(level*pdLEVEL+poFADE1+1+palpos[i])*3;
24575
24576 si += (c.first&15)*3;
24577
24578 for(int32_t col=c.first&15; col<=(c.count&15); col++)
24579 {
24580 RAMpal[CSET(c.first>>4)+col] = _RGB(si);
24581 si+=3;
24582 }
24583
24584 refreshpal = true;
24585 }
24586 }
24587 }
24588
24589 if(refreshpal)
24590 {
24591 rebuild_trans_table();
24592 zc_set_palette_range(RAMpal,0,192,false);
24593 }
24594 }
24595
24596
24597 /********************/
24598 /****** Help ******/
24599 /********************/
24600
24601 void doHelp()
24602 {
24603 do_box_edit(helpstr, "ZQuest Help", true, true);
24604 }
24605
24606 int32_t onHelp()
24607 {
24608 restore_mouse();
24609 doHelp();
24610 return D_O_K;
24611 }
24612
24613 void doZstringshelp()
24614 {
24615 do_box_edit(zstringshelpstr, "ZStrings Help", true, true);
24616 }
24617
24618 int32_t onZstringshelp()
24619 {
24620 restore_mouse();
24621 doZstringshelp();
24622 return D_O_K;
24623 }
24624
24625 static DIALOG layerdata_dlg[] =
24626 {
24627 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
24628 { jwin_win_proc, 16-12, 20+32, 288+1+24, 200+1-32-16, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Layer Data", NULL, NULL },
24629 { jwin_button_proc, 170, 180, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
24630 { jwin_button_proc, 90, 180, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
24631 // 3
24632 { jwin_rtext_proc, 72, 88, 40, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Map:", NULL, NULL },
24633 { jwin_rtext_proc, 72, 88+18, 48, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
24634 { jwin_rtext_proc, 72, 88+36, 56, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Transparent:", NULL, NULL },
24635 { jwin_ctext_proc, 89, 76, 8, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "1", NULL, NULL },
24636 { jwin_ctext_proc, 89+40, 76, 8, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "2", NULL, NULL },
24637 { jwin_ctext_proc, 89+80, 76, 8, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "3", NULL, NULL },
24638 { jwin_ctext_proc, 89+120, 76, 8, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "4", NULL, NULL },
24639 { jwin_ctext_proc, 89+160, 76, 8, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "5", NULL, NULL },
24640 { jwin_ctext_proc, 89+200, 76, 8, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "6", NULL, NULL },
24641
24642 //12
24643 { jwin_edit_proc, 76, 76+8, 32-6, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
24644 { d_hexedit_proc, 76, 76+18+8, 24-3, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
24645 { jwin_check_proc, 76, 76+40+8, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
24646
24647 { jwin_edit_proc, 76+40, 76+8, 32-6, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
24648 { d_hexedit_proc, 76+40, 76+18+8, 24-3, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
24649 { jwin_check_proc, 76+40, 76+40+8, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
24650
24651 { jwin_edit_proc, 76+80, 76+8, 32-6, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
24652 { d_hexedit_proc, 76+80, 76+18+8, 24-3, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
24653 { jwin_check_proc, 76+80, 76+40+8, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
24654
24655 { jwin_edit_proc, 76+120, 76+8, 32-6, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
24656 { d_hexedit_proc, 76+120, 76+18+8, 24-3, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
24657 { jwin_check_proc, 76+120, 76+40+8, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
24658
24659 { jwin_edit_proc, 76+160, 76+8, 32-6, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
24660 { d_hexedit_proc, 76+160, 76+18+8, 24-3, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
24661 { jwin_check_proc, 76+160, 76+40+8, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
24662
24663 { jwin_edit_proc, 76+200, 76+8, 32-6, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
24664 { d_hexedit_proc, 76+200, 76+18+8, 24-3, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
24665 { jwin_check_proc, 76+200, 76+40+8, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
24666
24667 //30
24668 { jwin_button_proc, 76, 76+40+18+8, 30, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Auto", NULL, NULL },
24669 { jwin_button_proc, 76+40, 76+40+18+8, 30, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Auto", NULL, NULL },
24670 { jwin_button_proc, 76+80, 76+40+18+8, 30, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Auto", NULL, NULL },
24671 { jwin_button_proc, 76+120, 76+40+18+8, 30, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Auto", NULL, NULL },
24672 { jwin_button_proc, 76+160, 76+40+18+8, 30, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Auto", NULL, NULL },
24673 { jwin_button_proc, 76+200, 76+40+18+8, 30, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Auto", NULL, NULL },
24674
24675 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
24676 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
24677
24678 };
24679
24680 int32_t edit_layers(mapscr* tempscr)
24681 {
24682 char buf[6][2][8];
24683 layerdata_dlg[0].dp2 = get_zc_font(font_lfont);
24684
24685 for(int32_t x=0; x<6; x++)
24686 {
24687 sprintf(buf[x][0],"%d",tempscr->layermap[x]);
24688 sprintf(buf[x][1],"%02X",tempscr->layerscreen[x]);
24689 }
24690
24691 for(int32_t x=0; x<6; x++)
24692 {
24693 for(int32_t y=0; y<2; y++)
24694 {
24695 layerdata_dlg[(x*3)+y+12].dp = buf[x][y];
24696 }
24697 }
24698
24699 for(int32_t x=0; x<6; x++)
24700 {
24701 layerdata_dlg[(x*3)+2+12].flags = (tempscr->layeropacity[x]<255) ? D_SELECTED : 0;
24702 }
24703
24704 large_dialog(layerdata_dlg);
24705
24706 int32_t ret=do_zqdialog(layerdata_dlg,0);
24707
24708 if(ret>=2)
24709 {
24710 for(int32_t x=0; x<6; x++)
24711 {
24712
24713 tempscr->layermap[x]=atoi(buf[x][0]);
24714
24715 if(tempscr->layermap[x]>map_count)
24716 {
24717 tempscr->layermap[x]=0;
24718 }
24719
24720 tempscr->layerscreen[x]=zc_xtoi(buf[x][1]);
24721
24722 if(zc_xtoi(buf[x][1])>=MAPSCRS)
24723 {
24724 tempscr->layerscreen[x]=0;
24725 }
24726
24727 // tempscr->layeropacity[x]=layerdata_dlg[(x*9)+8+19].flags & D_SELECTED ? 128:255;
24728 tempscr->layeropacity[x]=layerdata_dlg[(x*3)+2+12].flags & D_SELECTED ? 128:255;
24729 }
24730
24731 // } else if (ret>72&&ret<79) {
24732 // return (ret-72);
24733 }
24734
24735 return ret;
24736 }
24737
24738 static DIALOG autolayer_dlg[] =
24739 {
24740 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
24741 { jwin_win_proc, 64, 32+48, 192+1, 184+1-64, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Autolayer Setup", NULL, NULL },
24742 { jwin_text_proc, 76, 56+48, 136, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map for layer ?: ", NULL, NULL },
24743 { jwin_edit_proc, 212, 56+48, 32, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
24744 { jwin_check_proc, 76, 56+18+48, 153, 8, vc(14), vc(1), 0, D_EXIT, 1, 0, (void *) "Only Blank Screens", NULL, NULL },
24745 { jwin_button_proc, 90, 188-12, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
24746
24747 //5
24748 { jwin_button_proc, 170, 188-12, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
24749 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
24750 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
24751 { jwin_check_proc, 76, 56+28+48, 153, 8, vc(14), vc(1), 0, D_EXIT, 1, 0, (void *) "Only Blank Layers", NULL, NULL },
24752 { jwin_check_proc, 76, 56+38+48, 153, 8, vc(14), vc(1), 0, D_EXIT, 1, 0, (void *) "Overwrite Layers", NULL, NULL },
24753
24754 //10
24755 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
24756 };
24757 enum
24758 {
24759 autolyr_blankscreens,
24760 autolyr_blanklayers,
24761 autolyr_any
24762 };
24763 void autolayer(mapscr* tempscr, int32_t layer, int32_t al[6][3])
24764 {
24765 char tbuf[80],mlayer[80];
24766 autolayer_dlg[0].dp2=get_zc_font(font_lfont);
24767 sprintf(tbuf, "Map for layer %d: ", layer+1);
24768 autolayer_dlg[1].dp=tbuf;
24769 sprintf(mlayer, "%d", tempscr->layermap[layer]);
24770 autolayer_dlg[2].dp=mlayer;
24771
24772 large_dialog(autolayer_dlg);
24773 int ret, sel = 8, fl = autolyr_blanklayers;
24774 bool running = true;
24775 do
24776 {
24777 SETFLAG(autolayer_dlg[3].flags, D_SELECTED, sel==3);
24778 SETFLAG(autolayer_dlg[8].flags, D_SELECTED, sel==8);
24779 SETFLAG(autolayer_dlg[9].flags, D_SELECTED, sel==9);
24780 switch(ret=do_zqdialog(autolayer_dlg,0))
24781 {
24782 case 4: //OK
24783 {
24784 int32_t lmap=vbound(atoi(mlayer),0,Map.getMapCount());
24785 al[layer][0]=lmap;
24786 tempscr->layermap[layer]=lmap;
24787 tempscr->layerscreen[layer]=Map.getCurrScr();
24788 al[layer][1]=fl;
24789 al[layer][2]=1;
24790 running = false;
24791 break;
24792 }
24793 case 0: case 5: //cancel
24794 running = false;
24795 break;
24796 case 3:
24797 sel = ret;
24798 fl = autolyr_blankscreens;
24799 break;
24800 case 8:
24801 sel = ret;
24802 fl = autolyr_blanklayers;
24803 break;
24804 case 9:
24805 sel = ret;
24806 fl = autolyr_any;
24807 break;
24808 }
24809 }
24810 while(ret != 0 && ret != 4 && ret != 5);
24811 }
24812
24813 int32_t onLayers()
24814 {
24815 mapscr tempscr=*Map.CurrScr();
24816 int32_t al[6][3]; //autolayer[layer][0=map, 1=autolyr_ type, 2=bool go]
24817
24818 for(int32_t i=0; i<6; i++)
24819 {
24820 al[i][0]=tempscr.layermap[i];
24821 al[i][1]=0;
24822 al[i][2]=0;
24823 }
24824
24825 int32_t ret;
24826
24827 do
24828 {
24829 ret=edit_layers(&tempscr);
24830
24831 if(ret>2) //autolayer button
24832 {
24833 autolayer(&tempscr, ret-30, al);
24834 }
24835 }
24836 while(ret>2); //autolayer button
24837
24838 if(ret==2) //OK
24839 {
24840 saved=false;
24841 TheMaps[Map.getCurrMap()*MAPSCRS+Map.getCurrScr()]=tempscr;
24842
24843 for(int32_t i=0; i<6; i++)
24844 {
24845 int32_t tm=tempscr.layermap[i]-1;
24846 int32_t ts=tempscr.layerscreen[i];
24847
24848 if(al[i][2])
24849 {
24850 map_autolayers[Map.getCurrMap()*6+i] = al[i][0];
24851 for(int32_t j=0; j<128; j++)
24852 {
24853 auto& curmapscr = TheMaps[Map.getCurrMap()*MAPSCRS+j];
24854 if(al[i][1] == autolyr_blankscreens && (curmapscr.valid&mVALID))
24855 continue;
24856 else if(al[i][1] == autolyr_blanklayers && curmapscr.layermap[i])
24857 continue;
24858
24859 curmapscr.layermap[i]=al[i][0];
24860 curmapscr.layerscreen[i]=al[i][0]?j:0;
24861 }
24862 }
24863 }
24864 }
24865
24866 // Check that the working layer wasn't just disabled
24867 if(CurrentLayer>0 && tempscr.layermap[CurrentLayer-1]==0)
24868 CurrentLayer=0;
24869
24870 return D_O_K;
24871 }
24872
24873
24874 char *itoa(int32_t i)
24875 {
24876 static char itoaret[500];
24877 sprintf(itoaret, "%d", i);
24878 return itoaret;
24879 }
24880
24881 25 void fps_callback()
24882 {
24883 25 lastfps=framecnt;
24884 25 framecnt=0;
24885 25 }
24886
24887 END_OF_FUNCTION(fps_callback)
24888
24889 //uint32_t col_diff[3*128];
24890 /*
24891 void bestfit_init(void)
24892 {
24893 int32_t i;
24894
24895 for (i=1; i<64; i++)
24896
24897 {
24898 int32_t k = i * i;
24899 col_diff[0 +i] = col_diff[0 +128-i] = k * (59 * 59);
24900 col_diff[128+i] = col_diff[128+128-i] = k * (30 * 30);
24901 col_diff[256+i] = col_diff[256+128-i] = k * (11 * 11);
24902 }
24903 }
24904 */
24905 14 void create_rgb_table2(RGB_MAP *table, AL_CONST PALETTE pal, void (*callback)(int32_t pos))
24906 {
24907 #define UNUSED 65535
24908 #define LAST 65532
24909
24910 /* macro add adds to single linked list */
24911 #define add(i) (next[(i)] == UNUSED ? (next[(i)] = LAST, \
24912 (first != LAST ? (next[last] = (i)) : (first = (i))), \
24913 (last = (i))) : 0)
24914
24915 /* same but w/o checking for first element */
24916 #define add1(i) (next[(i)] == UNUSED ? (next[(i)] = LAST, \
24917 next[last] = (i), \
24918 (last = (i))) : 0)
24919 /* calculates distance between two colors */
24920 #define dist(a1, a2, a3, b1, b2, b3) \
24921 (col_diff[ ((a2) - (b2)) & 0x7F] + \
24922 (col_diff + 128)[((a1) - (b1)) & 0x7F] + \
24923 (col_diff + 256)[((a3) - (b3)) & 0x7F])
24924
24925 /* converts r,g,b to position in array and back */
24926 #define pos(r, g, b) \
24927 (((r) / 2) * 32 * 32 + ((g) / 2) * 32 + ((b) / 2))
24928
24929 #define depos(pal, r, g, b) \
24930 ((b) = ((pal) & 31) * 2, \
24931 (g) = (((pal) >> 5) & 31) * 2, \
24932 (r) = (((pal) >> 10) & 31) * 2)
24933
24934 /* is current color better than pal1? */
24935 #define better(r1, g1, b1, pal1) \
24936 (((int32_t)dist((r1), (g1), (b1), \
24937 (pal1).r, (pal1).g, (pal1).b)) > (int32_t)dist2)
24938
24939 /* checking of position */
24940 #define dopos(rp, gp, bp, ts) \
24941 if ((rp > -1 || r > 0) && (rp < 1 || r < 61) && \
24942 (gp > -1 || g > 0) && (gp < 1 || g < 61) && \
24943 (bp > -1 || b > 0) && (bp < 1 || b < 61)) \
24944 { \
24945 i = first + rp * 32 * 32 + gp * 32 + bp; \
24946 if (!data[i]) \
24947 { \
24948 data[i] = val; \
24949 add1(i); \
24950 } \
24951 else if ((ts) && (data[i] != val)) \
24952 { \
24953 dist2 = (rp ? (col_diff+128)[(r+2*rp-pal[val].r) & 0x7F] : r2) + \
24954 (gp ? (col_diff )[(g+2*gp-pal[val].g) & 0x7F] : g2) + \
24955 (bp ? (col_diff+256)[(b+2*bp-pal[val].b) & 0x7F] : b2); \
24956 if (better((r+2*rp), (g+2*gp), (b+2*bp), pal[data[i]])) \
24957 { \
24958 data[i] = val; \
24959 add1(i); \
24960 } \
24961 } \
24962 }
24963
24964 int32_t i, curr, r, g, b, val, dist2;
24965 uint32_t r2, g2, b2;
24966 uint16_t next[32*32*32];
24967 uint8_t *data;
24968 14 int32_t first = LAST;
24969 14 int32_t last = LAST;
24970 14 int32_t count = 0;
24971 14 int32_t cbcount = 0;
24972
24973 #define AVERAGE_COUNT 18000
24974
24975
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 6 times.
14 if(col_diff[1] == 0)
24976 8 bestfit_init();
24977
24978 14 memset(next, 255, sizeof(next));
24979 14 memset(table->data, 0, sizeof(char)*32*32*32);
24980
24981
24982 14 data = (uint8_t *)table->data;
24983
24984 /* add starting seeds for floodfill */
24985
2/2
✓ Branch 0 taken 3570 times.
✓ Branch 1 taken 14 times.
3584 for(i=1; i<PAL_SIZE; i++)
24986 {
24987 3570 curr = pos(pal[i].r, pal[i].g, pal[i].b);
24988
24989
2/2
✓ Branch 0 taken 2991 times.
✓ Branch 1 taken 579 times.
3570 if(next[curr] == UNUSED)
24990 {
24991 579 data[curr] = i;
24992
3/4
✓ Branch 0 taken 579 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 565 times.
✓ Branch 3 taken 14 times.
579 add(curr);
24993 579 }
24994 3570 }
24995
24996 /* main floodfill: two versions of loop for faster growing in blue axis */
24997 // while (first != LAST) {
24998
2/2
✓ Branch 0 taken 302531 times.
✓ Branch 1 taken 14 times.
302545 while(first < LAST)
24999 {
25000 302531 depos(first, r, g, b);
25001
25002 /* calculate distance of current color */
25003 302531 val = data[first];
25004 302531 r2 = (col_diff+128)[((pal[val].r)-(r)) & 0x7F];
25005 302531 g2 = (col_diff)[((pal[val].g)-(g)) & 0x7F];
25006 302531 b2 = (col_diff+256)[((pal[val].b)-(b)) & 0x7F];
25007
25008 /* try to grow to all directions */
25009 #ifdef _MSC_VER
25010 #pragma warning(disable:4127)
25011 #endif
25012
11/12
✓ Branch 0 taken 9725 times.
✓ Branch 1 taken 292806 times.
✓ Branch 2 taken 280999 times.
✓ Branch 3 taken 11807 times.
✓ Branch 4 taken 11807 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 237681 times.
✓ Branch 7 taken 43318 times.
✓ Branch 8 taken 10825 times.
✓ Branch 9 taken 32493 times.
✓ Branch 10 taken 21573 times.
✓ Branch 11 taken 10920 times.
583530 dopos(0, 0, 1, 1);
25013
11/12
✓ Branch 0 taken 8856 times.
✓ Branch 1 taken 293675 times.
✓ Branch 2 taken 283467 times.
✓ Branch 3 taken 10208 times.
✓ Branch 4 taken 10208 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 248463 times.
✓ Branch 7 taken 35004 times.
✓ Branch 8 taken 12300 times.
✓ Branch 9 taken 22704 times.
✓ Branch 10 taken 16016 times.
✓ Branch 11 taken 6688 times.
585998 dopos(0, 0,-1, 1);
25014
11/12
✓ Branch 0 taken 9770 times.
✓ Branch 1 taken 292761 times.
✓ Branch 2 taken 285391 times.
✓ Branch 3 taken 7370 times.
✓ Branch 4 taken 7370 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 238468 times.
✓ Branch 7 taken 46923 times.
✓ Branch 8 taken 29598 times.
✓ Branch 9 taken 17325 times.
✓ Branch 10 taken 11225 times.
✓ Branch 11 taken 6100 times.
587922 dopos(1, 0, 0, 1);
25015
11/12
✓ Branch 0 taken 9823 times.
✓ Branch 1 taken 292708 times.
✓ Branch 2 taken 285511 times.
✓ Branch 3 taken 7197 times.
✓ Branch 4 taken 7197 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 240894 times.
✓ Branch 7 taken 44617 times.
✓ Branch 8 taken 29388 times.
✓ Branch 9 taken 15229 times.
✓ Branch 10 taken 10206 times.
✓ Branch 11 taken 5023 times.
588042 dopos(-1, 0, 0, 1);
25016
11/12
✓ Branch 0 taken 9755 times.
✓ Branch 1 taken 292776 times.
✓ Branch 2 taken 264236 times.
✓ Branch 3 taken 28540 times.
✓ Branch 4 taken 28540 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 203207 times.
✓ Branch 7 taken 61029 times.
✓ Branch 8 taken 49629 times.
✓ Branch 9 taken 11400 times.
✓ Branch 10 taken 7693 times.
✓ Branch 11 taken 3707 times.
566767 dopos(0, 1, 0, 1);
25017
11/12
✓ Branch 0 taken 8682 times.
✓ Branch 1 taken 293849 times.
✓ Branch 2 taken 267858 times.
✓ Branch 3 taken 25991 times.
✓ Branch 4 taken 25991 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 208206 times.
✓ Branch 7 taken 59652 times.
✓ Branch 8 taken 49899 times.
✓ Branch 9 taken 9753 times.
✓ Branch 10 taken 6295 times.
✓ Branch 11 taken 3458 times.
570389 dopos(0,-1, 0, 1);
25018 #ifdef _MSC_VER
25019 #pragma warning(default:4127)
25020 #endif
25021
25022 /* faster growing of blue direction */
25023
4/4
✓ Branch 0 taken 293675 times.
✓ Branch 1 taken 8856 times.
✓ Branch 2 taken 12300 times.
✓ Branch 3 taken 281375 times.
302531 if((b > 0) && (data[first-1] == val))
25024 {
25025 281375 b -= 2;
25026 281375 first--;
25027 281375 b2 = (col_diff+256)[((pal[val].b)-(b)) & 0x7F];
25028
25029 #ifdef _MSC_VER
25030 #pragma warning(disable:4127)
25031 #endif
25032
5/6
✓ Branch 0 taken 9170 times.
✓ Branch 1 taken 272205 times.
✓ Branch 2 taken 248616 times.
✓ Branch 3 taken 23589 times.
✓ Branch 4 taken 23589 times.
✗ Branch 5 not taken.
529991 dopos(-1, 0, 0, 0);
25033
5/6
✓ Branch 0 taken 9153 times.
✓ Branch 1 taken 272222 times.
✓ Branch 2 taken 247116 times.
✓ Branch 3 taken 25106 times.
✓ Branch 4 taken 25106 times.
✗ Branch 5 not taken.
528491 dopos(1, 0, 0, 0);
25034
5/6
✓ Branch 0 taken 8131 times.
✓ Branch 1 taken 273244 times.
✓ Branch 2 taken 239635 times.
✓ Branch 3 taken 33609 times.
✓ Branch 4 taken 33609 times.
✗ Branch 5 not taken.
521010 dopos(0,-1, 0, 0);
25035
5/6
✓ Branch 0 taken 9185 times.
✓ Branch 1 taken 272190 times.
✓ Branch 2 taken 229695 times.
✓ Branch 3 taken 42495 times.
✓ Branch 4 taken 42495 times.
✗ Branch 5 not taken.
511070 dopos(0, 1, 0, 0);
25036 #ifdef _MSC_VER
25037 #pragma warning(default:4127)
25038 #endif
25039
25040 281375 first++;
25041 281375 }
25042
25043 /* get next from list */
25044 302531 i = first;
25045 302531 first = next[first];
25046 302531 next[i] = UNUSED;
25047
25048 /* second version of loop */
25049 // if (first != LAST) {
25050
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 302523 times.
302531 if(first < LAST)
25051 {
25052
25053 302523 depos(first, r, g, b);
25054
25055 302523 val = data[first];
25056 302523 r2 = (col_diff+128)[((pal[val].r)-(r)) & 0x7F];
25057 302523 g2 = (col_diff)[((pal[val].g)-(g)) & 0x7F];
25058 302523 b2 = (col_diff+256)[((pal[val].b)-(b)) & 0x7F];
25059
25060 #ifdef _MSC_VER
25061 #pragma warning(disable:4127)
25062 #endif
25063
11/12
✓ Branch 0 taken 9328 times.
✓ Branch 1 taken 293195 times.
✓ Branch 2 taken 279417 times.
✓ Branch 3 taken 13778 times.
✓ Branch 4 taken 13778 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 235908 times.
✓ Branch 7 taken 43509 times.
✓ Branch 8 taken 10900 times.
✓ Branch 9 taken 32609 times.
✓ Branch 10 taken 21621 times.
✓ Branch 11 taken 10988 times.
581940 dopos(0, 0, 1, 1);
25064
11/12
✓ Branch 0 taken 8791 times.
✓ Branch 1 taken 293732 times.
✓ Branch 2 taken 285172 times.
✓ Branch 3 taken 8560 times.
✓ Branch 4 taken 8560 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 250121 times.
✓ Branch 7 taken 35051 times.
✓ Branch 8 taken 12558 times.
✓ Branch 9 taken 22493 times.
✓ Branch 10 taken 15978 times.
✓ Branch 11 taken 6515 times.
587695 dopos(0, 0,-1, 1);
25065
11/12
✓ Branch 0 taken 9873 times.
✓ Branch 1 taken 292650 times.
✓ Branch 2 taken 285045 times.
✓ Branch 3 taken 7605 times.
✓ Branch 4 taken 7605 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 238005 times.
✓ Branch 7 taken 47040 times.
✓ Branch 8 taken 29755 times.
✓ Branch 9 taken 17285 times.
✓ Branch 10 taken 11170 times.
✓ Branch 11 taken 6115 times.
587568 dopos(1, 0, 0, 1);
25066
11/12
✓ Branch 0 taken 9691 times.
✓ Branch 1 taken 292832 times.
✓ Branch 2 taken 285774 times.
✓ Branch 3 taken 7058 times.
✓ Branch 4 taken 7058 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 241098 times.
✓ Branch 7 taken 44676 times.
✓ Branch 8 taken 29502 times.
✓ Branch 9 taken 15174 times.
✓ Branch 10 taken 10413 times.
✓ Branch 11 taken 4761 times.
588297 dopos(-1, 0, 0, 1);
25067
11/12
✓ Branch 0 taken 9746 times.
✓ Branch 1 taken 292777 times.
✓ Branch 2 taken 264527 times.
✓ Branch 3 taken 28250 times.
✓ Branch 4 taken 28250 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 203812 times.
✓ Branch 7 taken 60715 times.
✓ Branch 8 taken 49448 times.
✓ Branch 9 taken 11267 times.
✓ Branch 10 taken 7628 times.
✓ Branch 11 taken 3639 times.
567050 dopos(0, 1, 0, 1);
25068
11/12
✓ Branch 0 taken 8525 times.
✓ Branch 1 taken 293998 times.
✓ Branch 2 taken 268987 times.
✓ Branch 3 taken 25011 times.
✓ Branch 4 taken 25011 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 208947 times.
✓ Branch 7 taken 60040 times.
✓ Branch 8 taken 50245 times.
✓ Branch 9 taken 9795 times.
✓ Branch 10 taken 6484 times.
✓ Branch 11 taken 3311 times.
571510 dopos(0,-1, 0, 1);
25069 #ifdef _MSC_VER
25070 #pragma warning(default:4127)
25071 #endif
25072
25073
4/4
✓ Branch 0 taken 293195 times.
✓ Branch 1 taken 9328 times.
✓ Branch 2 taken 10900 times.
✓ Branch 3 taken 282295 times.
302523 if((b < 61) && (data[first + 1] == val))
25074 {
25075 282295 b += 2;
25076 282295 first++;
25077 282295 b2 = (col_diff+256)[((pal[val].b)-(b)) & 0x7f];
25078 #ifdef _MSC_VER
25079 #pragma warning(disable:4127)
25080 #endif
25081
5/6
✓ Branch 0 taken 9100 times.
✓ Branch 1 taken 273195 times.
✓ Branch 2 taken 246061 times.
✓ Branch 3 taken 27134 times.
✓ Branch 4 taken 27134 times.
✗ Branch 5 not taken.
528356 dopos(-1, 0, 0, 0);
25082
5/6
✓ Branch 0 taken 9222 times.
✓ Branch 1 taken 273073 times.
✓ Branch 2 taken 239182 times.
✓ Branch 3 taken 33891 times.
✓ Branch 4 taken 33891 times.
✗ Branch 5 not taken.
521477 dopos(1, 0, 0, 0);
25083
5/6
✓ Branch 0 taken 7952 times.
✓ Branch 1 taken 274343 times.
✓ Branch 2 taken 228378 times.
✓ Branch 3 taken 45965 times.
✓ Branch 4 taken 45965 times.
✗ Branch 5 not taken.
510673 dopos(0,-1, 0, 0);
25084
5/6
✓ Branch 0 taken 9289 times.
✓ Branch 1 taken 273006 times.
✓ Branch 2 taken 227997 times.
✓ Branch 3 taken 45009 times.
✓ Branch 4 taken 45009 times.
✗ Branch 5 not taken.
510292 dopos(0, 1, 0, 0);
25085 #ifdef _MSC_VER
25086 #pragma warning(default:4127)
25087 #endif
25088
25089 282295 first--;
25090 282295 }
25091
25092 302523 i = first;
25093 302523 first = next[first];
25094 302523 next[i] = UNUSED;
25095 302523 }
25096
25097 302531 count++;
25098
25099
2/2
✓ Branch 0 taken 298933 times.
✓ Branch 1 taken 3598 times.
302531 if(count == (cbcount+1)*AVERAGE_COUNT/256)
25100 {
25101
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 3584 times.
3598 if(cbcount < 256)
25102 {
25103
1/2
✓ Branch 0 taken 3584 times.
✗ Branch 1 not taken.
3584 if(callback)
25104 callback(cbcount);
25105
25106 3584 cbcount++;
25107 3584 }
25108 3598 }
25109
25110 }
25111
25112 /* only the transparent (pink) color can be mapped to index 0 */
25113
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
14 if((pal[0].r == 63) && (pal[0].g == 0) && (pal[0].b == 63))
25114 table->data[31][0][31] = 0;
25115
25116
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(callback)
25117 while(cbcount < 256)
25118 callback(cbcount++);
25119 14 }
25120
25121 14 void rebuild_trans_table()
25122 {
25123 14 create_rgb_table2(&zq_rgb_table, RAMpal, NULL);
25124 14 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
25125 14 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
25126
25127
2/2
✓ Branch 0 taken 3584 times.
✓ Branch 1 taken 14 times.
3598 for(int32_t q=0; q<PAL_SIZE; q++)
25128 {
25129 3584 trans_table2.data[0][q] = q;
25130 3584 trans_table2.data[q][q] = q;
25131 3584 }
25132 14 }
25133
25134 int32_t isFullScreen()
25135 {
25136 return !is_windowed_mode();
25137 }
25138
25139 void hit_close_button()
25140 {
25141 close_button_quit=true;
25142 return;
25143 }
25144
25145 /********************/
25146 /****** MAIN ******/
25147 /********************/
25148
25149 /*
25150 enum { jcBOX, jcLIGHT, jcMEDLT, jcMEDDARK, jcDARK, jcBOXFG,
25151 jcTITLEL, jcTITLER, jcTITLEFG, jcTEXTBG, jcTEXTFG, jcSELBG, jcSELFG,
25152 jcMAX };
25153
25154 enum { light gray, white, off-white, gray, dark gray, black,
25155 jcTITLEL, jcTITLER, jcTITLEFG, jcTEXTBG, jcTEXTFG, jcSELBG, jcSELFG,
25156 jcMAX };
25157 */
25158
25159 extern bool dirty_screen;
25160
25161 /*
25162 static int32_t jwin_pal[jcMAX] =
25163 {
25164 vc(11),vc(15),vc(4),vc(7),vc(6),vc(0),
25165 192,223,vc(14),vc(15),vc(0),vc(1),vc(14)
25166 };
25167 */
25168
25169 void anim_hw_screen(bool force)
25170 {
25171 if(force || myvsync)
25172 {
25173 ++cpoolbrush_index;
25174
25175 if(prv_mode)
25176 {
25177 if(Map.get_prvtime())
25178 {
25179 Map.set_prvtime(Map.get_prvtime()-1);
25180
25181 if(!Map.get_prvtime())
25182 {
25183 prv_warp=1;
25184 }
25185 }
25186 }
25187 if(AnimationOn)
25188 {
25189 animate_combos();
25190 update_freeform_combos();
25191 }
25192
25193 if(CycleOn)
25194 cycle_palette();
25195
25196 animate_coords();
25197 update_hw_screen(true);
25198 }
25199 }
25200
25201 void custom_vsync()
25202 {
25203 throttleFPS(60);
25204 anim_hw_screen(true);
25205 myvsync=0;
25206 }
25207
25208 void switch_out()
25209 {
25210 zcmusic_pause(zcmusic, ZCM_PAUSE);
25211 zc_midi_pause();
25212 }
25213
25214 void switch_in()
25215 {
25216 if(exiting_program)
25217 return;
25218 zcmusic_pause(zcmusic, ZCM_RESUME);
25219 zc_midi_resume();
25220 }
25221
25222 void Z_eventlog(const char *format,...)
25223 {
25224 format=format; //to prevent a compiler warning
25225 }
25226
25227 int32_t get_currdmap()
25228 {
25229 return zinit.start_dmap;
25230 }
25231
25232 int32_t get_dlevel()
25233 {
25234 return DMaps[zinit.start_dmap].level;
25235 }
25236
25237 int32_t get_currscr()
25238 {
25239 return Map.getCurrScr();
25240 }
25241
25242 int32_t get_currmap()
25243 {
25244 return Map.getCurrMap();
25245 }
25246
25247 int32_t get_homescr()
25248 {
25249 return DMaps[zinit.start_dmap].cont;
25250 }
25251
25252 int current_item(int item_type, bool checkmagic, bool jinx_check, bool check_bunny)
25253 {
25254 //TODO remove as special case?? -DD
25255 if(item_type==itype_shield)
25256 {
25257 return 2;
25258 }
25259
25260 int id = current_item_id(item_type, checkmagic, jinx_check, check_bunny);
25261 return id > -1 ? itemsbuf[id].fam_type : 0;
25262 }
25263
25264 int current_item_power(int itemtype, bool checkmagic, bool jinx_check, bool check_bunny)
25265 {
25266 if (game)
25267 {
25268 int result = current_item_id(itemtype, checkmagic, jinx_check, check_bunny);
25269 return (result<0) ? 0 : itemsbuf[result].power;
25270 }
25271 return 1;
25272 }
25273
25274 int32_t current_item_id(int32_t itemtype, bool, bool, bool)
25275 {
25276 if (game)
25277 {
25278 int32_t result = -1;
25279 int32_t highestlevel = -1;
25280
25281 for (int32_t i = 0; i < MAXITEMS; i++)
25282 {
25283 if ((zq_ignore_item_ownership || game->get_item(i)) && itemsbuf[i].family == itemtype)
25284 {
25285 if (itemsbuf[i].fam_type >= highestlevel)
25286 {
25287 highestlevel = itemsbuf[i].fam_type;
25288 result = i;
25289 }
25290 }
25291 }
25292 return result;
25293 }
25294 for(int32_t i=0; i<MAXITEMS; i++)
25295 {
25296 if(itemsbuf[i].family==itemtype)
25297 return i;
25298 }
25299
25300 return -1;
25301 }
25302
25303
25304 bool can_use_item(int32_t item_type, int32_t item)
25305 {
25306 //these are here to bypass compiler warnings about unused arguments
25307 item_type=item_type;
25308 item=item;
25309
25310 return true;
25311 }
25312
25313 bool has_item(int32_t item_type, int32_t it)
25314 {
25315 //these are here to bypass compiler warnings about unused arguments
25316 item_type=item_type;
25317 it=it;
25318
25319 return true;
25320 }
25321
25322 int32_t get_bmaps(int32_t si)
25323 {
25324 //these are here to bypass compiler warnings about unused arguments
25325 si=si;
25326
25327 return 255;
25328 }
25329
25330 bool no_subscreen()
25331 {
25332 return false;
25333 }
25334
25335 8 static void allocate_crap()
25336 {
25337 8 filepath=(char*)malloc(2048);
25338 8 temppath=(char*)malloc(2048);
25339 8 datapath=(char*)malloc(2048);
25340 8 midipath=(char*)malloc(2048);
25341 8 imagepath=(char*)malloc(2048);
25342 8 tmusicpath=(char*)malloc(2048);
25343 8 last_timed_save=(char*)malloc(2048);
25344
25345
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!filepath || !datapath || !temppath || !imagepath || !midipath || !tmusicpath || !last_timed_save)
25346 {
25347 Z_error_fatal("Error: no memory for file paths!");
25348 }
25349
25350
25351 8 customtunes = (zctune*)malloc(sizeof(class zctune)*MAXCUSTOMMIDIS_ZQ);
25352 8 memset(customtunes, 0, sizeof(class zctune)*MAXCUSTOMMIDIS_ZQ);
25353
25354
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 8 times.
2056 for(int32_t i=0; i<MAXCUSTOMMIDIS_ZQ; ++i)
25355 {
25356 2048 customtunes[i].data=NULL;
25357 2048 }
25358
25359
2/2
✓ Branch 0 taken 2016 times.
✓ Branch 1 taken 8 times.
2024 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
25360 {
25361 2016 midi_string[i+4]=customtunes[i].title;
25362 2016 screen_midi_string[i+5]=customtunes[i].title;
25363 2016 }
25364
25365
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 8 times.
2056 for(int32_t i=0; i<WAV_COUNT; i++)
25366 {
25367
1/4
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2048 if(sfx_string[i]!=NULL) delete sfx_string[i];
25368 2048 customsfxdata[i].data=NULL;
25369 2048 sfx_string[i] = new char[36];
25370 2048 memset(sfx_string[i], 0, 36);
25371 2048 }
25372
25373
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 8 times.
2056 for(int32_t i=0; i<MAXWPNS; i++)
25374 {
25375
1/4
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2048 if(weapon_string[i]!=NULL) delete weapon_string[i];
25376 2048 weapon_string[i] = new char[64];
25377 2048 memset(weapon_string[i], 0, 64);
25378 2048 }
25379
25380
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 8 times.
2056 for(int32_t i=0; i<MAXITEMS; i++)
25381 {
25382
1/4
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2048 if(item_string[i]!=NULL) delete item_string[i];
25383 2048 item_string[i] = new char[64];
25384 2048 memset(item_string[i], 0, 64);
25385 2048 }
25386
25387
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 8 times.
4104 for(int32_t i=0; i<eMAXGUYS; i++)
25388 {
25389
1/4
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4096 if(guy_string[i]!=NULL) delete guy_string[i];
25390 4096 guy_string[i] = new char[64];
25391 4096 memset(guy_string[i], 0, 64);
25392 4096 }
25393
25394
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 8 times.
4104 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
25395 {
25396
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 delete ffscripts[i];
25397
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 ffscripts[i] = new script_data(ScriptType::FFC, i);
25398 4096 }
25399
25400
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 8 times.
2056 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
25401 {
25402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2048 times.
2048 delete itemscripts[i];
25403
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 itemscripts[i] = new script_data(ScriptType::Item, i);
25404 2048 }
25405
25406
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 8 times.
2056 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
25407 {
25408
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 delete guyscripts[i];
25409
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 guyscripts[i] = new script_data(ScriptType::NPC, i);
25410 2048 }
25411
25412
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 8 times.
2056 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
25413 {
25414
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 delete screenscripts[i];
25415
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 screenscripts[i] = new script_data(ScriptType::Screen, i);
25416 2048 }
25417
25418
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 8 times.
72 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
25419 {
25420
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 delete globalscripts[i];
25421
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 globalscripts[i] = new script_data(ScriptType::Global, i);
25422 64 }
25423
25424
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 8 times.
48 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
25425 {
25426
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 delete playerscripts[i];
25427
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 playerscripts[i] = new script_data(ScriptType::Player, i);
25428 40 }
25429
25430
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 8 times.
2056 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
25431 {
25432
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 delete lwpnscripts[i];
25433
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 lwpnscripts[i] = new script_data(ScriptType::Lwpn, i);
25434 2048 }
25435
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 8 times.
2056 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
25436 {
25437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2048 times.
2048 delete ewpnscripts[i];
25438
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 ewpnscripts[i] = new script_data(ScriptType::Ewpn, i);
25439 2048 }
25440
25441
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 8 times.
2056 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
25442 {
25443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2048 times.
2048 delete dmapscripts[i];
25444
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 dmapscripts[i] = new script_data(ScriptType::DMap, i);
25445 2048 }
25446
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 8 times.
2056 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
25447 {
25448
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 delete itemspritescripts[i];
25449
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 itemspritescripts[i] = new script_data(ScriptType::ItemSprite, i);
25450 2048 }
25451
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 8 times.
4104 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
25452 {
25453
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 delete comboscripts[i];
25454
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 comboscripts[i] = new script_data(ScriptType::Combo, i);
25455 4096 }
25456
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 8 times.
4104 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
25457 {
25458
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 delete genericscripts[i];
25459
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 genericscripts[i] = new script_data(ScriptType::Generic, i);
25460 4096 }
25461
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 8 times.
2056 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
25462 {
25463
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 delete subscreenscripts[i];
25464
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 subscreenscripts[i] = new script_data(ScriptType::EngineSubscreen, i);
25465 2048 }
25466 8 }
25467
25468 // Removes the top layer encoding from a quest file. See open_quest_file.
25469 // This has zero impact on the contents of the quest file. There should be no way for this to
25470 // break anything.
25471 static void do_unencrypt_qst_command(const char* input_filename, const char* output_filename)
25472 {
25473 // If the file is already an unencrypted packfile, there's nothing to do.
25474 PACKFILE* pf_check = pack_fopen_password(input_filename, F_READ_PACKED, "");
25475 pack_fclose(pf_check);
25476 if (pf_check) return;
25477
25478 int32_t error;
25479 PACKFILE* pf = open_quest_file(&error, input_filename, false);
25480 PACKFILE* pf2 = pack_fopen_password(output_filename, F_WRITE_PACKED, "");
25481 int c;
25482 while ((c = pack_getc(pf)) != EOF)
25483 {
25484 pack_putc(c, pf2);
25485 }
25486 pack_fclose(pf);
25487 pack_fclose(pf2);
25488 clear_quest_tmpfile();
25489 }
25490
25491 // This will remove the PACKFILE compression. Incidentally, it also removes the top encoding layer.
25492 static void do_uncompress_qst_command(const char* input_filename, const char* output_filename)
25493 {
25494 auto unencrypted_result = try_open_maybe_legacy_encoded_file(input_filename, ENC_STR, nullptr, QH_NEWIDSTR, QH_IDSTR);
25495 if (unencrypted_result.not_found)
25496 {
25497 printf("qst not found\n");
25498 exit(1);
25499 }
25500 if (!unencrypted_result.compressed && !unencrypted_result.encrypted)
25501 {
25502 // If the file is already an uncompressed file, there's nothing to do but copy it.
25503 fs::copy(input_filename, output_filename);
25504 return;
25505 }
25506
25507 pack_fclose(unencrypted_result.decoded_pf);
25508
25509 int32_t error;
25510 PACKFILE* pf = open_quest_file(&error, input_filename, false);
25511 PACKFILE* pf2 = pack_fopen_password(output_filename, F_WRITE, "");
25512 int c;
25513 while ((c = pack_getc(pf)) != EOF)
25514 {
25515 pack_putc(c, pf2);
25516 }
25517 pack_fclose(pf);
25518 pack_fclose(pf2);
25519 clear_quest_tmpfile();
25520 }
25521
25522 // Copy a quest file by loading and resaving, exactly like if the user did it in the UI.
25523 // Note there could be changes introduced in the loading or saving functions. These are
25524 // typically for compatability, but could possibly be a source of bugs.
25525 2 static void do_copy_qst_command(const char* input_filename, const char* output_filename)
25526 {
25527 2 set_headless_mode();
25528
25529 // We need to init some stuff before loading a quest file will work.
25530 2 int fake_errno = 0;
25531 2 allegro_errno = &fake_errno;
25532 2 get_qst_buffers();
25533
25534 2 int ret = load_quest(input_filename, false);
25535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (ret)
25536 {
25537 exit(ret);
25538 }
25539
25540 2 ret = save_quest(output_filename, false);
25541 2 exit(ret);
25542 }
25543
25544 int32_t Awpn=-1, Bwpn=-1, Xwpn = -1, Ywpn = -1;
25545 56 sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations, portals;
25546 int32_t exittimer = 10000, exittimer2 = 100;
25547
25548 1 static bool partial_load_test(const char* test_dir)
25549 {
25550 1 int ret = load_quest("quests/Z1 Recreations/classic_1st.qst", false);
25551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (ret)
25552 {
25553 printf("failed to load classic_1st.qst: ret == %d\n", ret);
25554 return false;
25555 }
25556
25557 1 int cont = DMaps[0].cont;
25558
25559 // Skip same stuff as used in zq_tiles.cpp for grabbing tiles from a qst.
25560 byte skip_flags[4];
25561
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 1 times.
27 for (int i=0; i<skip_max; ++i)
25562 26 set_bit(skip_flags,i,1);
25563 1 set_bit(skip_flags,skip_tiles,0);
25564 1 set_bit(skip_flags,skip_header,0);
25565 zquestheader tempheader;
25566 1 memset(&tempheader, 0, sizeof(zquestheader));
25567
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 auto ptux_path = fs::path(test_dir) / "quests/PTUX.qst";
25568
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 ret = loadquest(ptux_path.string().c_str(), &tempheader, &QMisc, customtunes, false, skip_flags);
25569
25570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (ret)
25571 {
25572 printf("failed to load PTUX.qst: ret == %d\n", ret);
25573 return false;
25574 }
25575
25576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (DMaps[0].cont != cont)
25577 {
25578 printf("unexpected modification: DMaps[0].cont == %d, should be %d\n", DMaps[0].cont, cont);
25579 return false;
25580 }
25581
25582 // TODO should run replay. Currently, resaving classic_1st.qst fails its replay (see test_save in test_zeditor.py)
25583
25584 1 return true;
25585 1 }
25586
25587 template <typename ...Params>
25588 [[noreturn]] void FatalConsole(const char *format, Params&&... params)
25589 {
25590 FFCore.ZScriptConsole(CConsoleLoggerEx::COLOR_RED|CConsoleLoggerEx::COLOR_INTENSITY|CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"");
25591 Z_error_fatal(format, std::forward<Params>(params)...);
25592 }
25593
25594 6 int32_t main(int32_t argc,char **argv)
25595 {
25596 6 int test_zc_arg = used_switch(argc, argv, "-test-zc");
25597
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 if (test_zc_arg > 0)
25598 1 set_headless_mode();
25599
25600 6 zalleg_setup_allegro(App::zquest, argc, argv);
25601 6 allocate_crap();
25602
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 set_should_zprint_cb([]() {
25603 return get_qr(qr_SCRIPTERRLOG) || DEVLEVEL > 0;
25604 });
25605
25606 6 int package_arg = used_switch(argc, argv, "-package");
25607
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (package_arg > 0)
25608 {
25609 if (package_arg + 3 > argc)
25610 {
25611 printf("%d\n", argc);
25612 printf("expected -package <game.qst> <package name>\n");
25613 exit(1);
25614 }
25615
25616 const char* input_filename = argv[package_arg + 1];
25617 const char* package_name = argv[package_arg + 2];
25618 if (auto error = package_create(input_filename, package_name))
25619 Z_error_fatal("%s\n", error->c_str());
25620 exit(0);
25621 }
25622
25623 6 int copy_qst_arg = used_switch(argc, argv, "-copy-qst");
25624
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
6 if (copy_qst_arg > 0)
25625 {
25626
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (copy_qst_arg + 3 > argc)
25627 {
25628 printf("%d\n", argc);
25629 printf("expected -copy-qst <input> <output>\n");
25630 exit(1);
25631 }
25632
25633 2 const char* input_filename = argv[copy_qst_arg + 1];
25634 2 const char* output_filename = argv[copy_qst_arg + 2];
25635 2 do_copy_qst_command(input_filename, output_filename);
25636 2 }
25637
25638 6 Z_title("%s, %s",ZQ_EDITOR_NAME, getVersionString());
25639
25640
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!get_qst_buffers())
25641 {
25642 Z_error_fatal("Error");
25643 }
25644
25645 6 undocombobuf.clear();
25646 6 undocombobuf.resize(MAXCOMBOS);
25647
25648
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if((newundotilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
25649 {
25650 Z_error_fatal("Error: no memory for tile undo buffer!");
25651 }
25652
25653 6 memset(newundotilebuf, 0, NEWMAXTILES*sizeof(tiledata));
25654
25655 6 Z_message("Resetting new tile buffer...");
25656 6 newtilebuf = (tiledata*)malloc(NEWMAXTILES*sizeof(tiledata));
25657
25658
2/2
✓ Branch 0 taken 1287000 times.
✓ Branch 1 taken 6 times.
1287006 for(int32_t j=0; j<NEWMAXTILES; j++)
25659 1287000 newtilebuf[j].data=NULL;
25660
25661 6 Z_message("OK\n");
25662
25663 6 zc_srand(time(0));
25664
25665
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 if (test_zc_arg > 0)
25666 {
25667 1 set_headless_mode();
25668
25669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (test_zc_arg + 1 > argc)
25670 {
25671 printf("%d\n", argc);
25672 printf("expected -test-zc <path to test dir>\n");
25673 exit(1);
25674 }
25675
25676 1 const char* test_dir = argv[test_zc_arg + 1];
25677
25678 // We need to init some stuff before loading a quest file will work.
25679 1 int fake_errno = 0;
25680 1 allegro_errno = &fake_errno;
25681 1 get_qst_buffers();
25682
25683 1 bool success = true;
25684
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (!partial_load_test(test_dir))
25685 {
25686 success = false;
25687 printf("partial_load_test failed\n");
25688 }
25689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (success)
25690 1 printf("all tests passed\n");
25691 1 exit(success ? 0 : 1);
25692 }
25693
25694 5 int unencrypt_qst_arg = used_switch(argc, argv, "-unencrypt-qst");
25695
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (unencrypt_qst_arg > 0)
25696 {
25697 if (unencrypt_qst_arg + 3 > argc)
25698 {
25699 printf("%d\n", argc);
25700 printf("expected -unencrypt-qst <input> <output>\n");
25701 exit(1);
25702 }
25703
25704 const char* input_filename = argv[unencrypt_qst_arg + 1];
25705 const char* output_filename = argv[unencrypt_qst_arg + 2];
25706 do_unencrypt_qst_command(input_filename, output_filename);
25707 exit(0);
25708 }
25709
25710 5 int uncompress_qst_arg = used_switch(argc, argv, "-uncompress-qst");
25711
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (uncompress_qst_arg > 0)
25712 {
25713 if (uncompress_qst_arg + 3 > argc)
25714 {
25715 printf("%d\n", argc);
25716 printf("expected -uncompress-qst <input> <output>\n");
25717 exit(1);
25718 }
25719
25720 const char* input_filename = argv[uncompress_qst_arg + 1];
25721 const char* output_filename = argv[uncompress_qst_arg + 2];
25722 do_uncompress_qst_command(input_filename, output_filename);
25723 exit(0);
25724 }
25725
25726 5 three_finger_flag=false;
25727
25728 #ifndef __EMSCRIPTEN__
25729
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(zc_get_config("zquest","open_debug_console",0))
25730 initConsole();
25731 #endif
25732
25733 LOCK_VARIABLE(lastfps);
25734
25735 LOCK_VARIABLE(framecnt);
25736 LOCK_FUNCTION(fps_callback);
25737
25738
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
25739 {
25740 Z_error_fatal("couldn't allocate timer");
25741 }
25742
25743
25744 LOCK_VARIABLE(dclick_status);
25745 LOCK_VARIABLE(dclick_time);
25746 5 lock_dclick_function();
25747 5 install_int(dclick_check, 20);
25748
25749 5 set_gfx_mode(GFX_TEXT,80,50,0,0);
25750
25751 5 Z_message("Loading data files:\n");
25752
25753 5 packfile_password(datapwd);
25754
25755 5 Z_message("ZQuest.Dat...");
25756
25757
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if((zcdata=load_datafile(moduledata.datafiles[zquest_dat]))==NULL)
25758 FatalConsole("failed to load zquest.dat");
25759
25760 5 Z_message("OK\n");
25761
25762 5 packfile_password("");
25763
25764
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 helpstr = util::read_text_file("docs/zquest.txt");
25765
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 zstringshelpstr = util::read_text_file("docs/zstrings.txt");
25766
25767 // loading data files...
25768
25769 5 filepath[0]=temppath[0]=0;
25770
25771 5 const char *default_path="";
25772
25773 5 strcpy(datapath,zc_get_config("zquest",data_path_name,default_path));
25774 5 strcpy(midipath,zc_get_config("zquest",midi_path_name,default_path));
25775 5 strcpy(imagepath,zc_get_config("zquest",image_path_name,default_path));
25776 5 strcpy(tmusicpath,zc_get_config("zquest",tmusic_path_name,default_path));
25777 5 chop_path(datapath);
25778 5 chop_path(midipath);
25779 5 chop_path(imagepath);
25780 5 chop_path(tmusicpath);
25781
25782 5 DisableLPalShortcuts = zc_get_config("zquest","dis_lpal_shortcut",1);
25783 5 DisableCompileConsole = zc_get_config("zquest","internal_compile_console",0);
25784 5 MouseScroll = zc_get_config("zquest","mouse_scroll",0);
25785 5 WarnOnInitChanged = zc_get_config("zquest","warn_initscript_changes",1);
25786 5 MMapCursorStyle = zc_get_config("zquest","cursorblink_style",1);
25787 5 LayerDitherBG = zc_get_config("zquest", "layer_dither_bg", -1);
25788 5 LayerDitherSz = zc_get_config("zquest", "layer_dither_sz", 3);
25789 5 InvalidBG = zc_get_config("zquest", "invalid_bg", 0);
25790 5 TileProtection = zc_get_config("zquest","tile_protection",1);
25791 5 ComboProtection = zc_get_config("zquest","combo_protection",TileProtection);
25792 5 ShowGrid = zc_get_config("zquest","show_grid",0);
25793 5 GridColor = zc_get_config("zquest","grid_color",15);
25794 5 CmbCursorCol = zc_get_config("zquest","combo_cursor_color",15);
25795 5 TilePgCursorCol = zc_get_config("zquest","tpage_cursor_color",15);
25796 5 CmbPgCursorCol = zc_get_config("zquest","cpage_cursor_color",15);
25797 5 TTipHLCol = zc_get_config("zquest","ttip_hl_color",13);
25798 5 CheckerCol1 = zc_get_config("zquest","checker_color_1",7);
25799 5 CheckerCol2 = zc_get_config("zquest","checker_color_2",8);
25800 5 SnapshotFormat = zc_get_config("zquest","snapshot_format",3);
25801 5 SnapshotScale = zc_get_config("zquest","snapshot_scale",2);
25802 5 SavePaths = zc_get_config("zquest","save_paths",1);
25803 5 CycleOn = zc_get_config("zquest","cycle_on",1);
25804 5 ShowFPS = zc_get_config("zquest","showfps",0)!=0;
25805 5 SaveDragResize = zc_get_config("zquest","save_drag_resize",0)!=0;
25806 5 DragAspect = zc_get_config("zquest","drag_aspect",0)!=0;
25807 5 SaveWinPos = zc_get_config("zquest","save_window_position",0)!=0;
25808 5 ComboBrush = zc_get_config("zquest","combo_brush",0);
25809 5 FloatBrush = zc_get_config("zquest","float_brush",0);
25810 5 AutoBrush = zc_get_config("zquest","autobrush",1);
25811 5 LinkedScroll = zc_get_config("zquest","linked_comboscroll",0);
25812 5 allowHideMouse = zc_get_config("ZQ_GUI","allowHideMouse",0);
25813 5 ShowFavoriteComboModes = zc_get_config("ZQ_GUI","show_fav_combo_modes",1);
25814 5 NoHighlightLayer0 = zc_get_config("zquest","no_highlight_layer0",0);
25815 5 RulesetDialog = zc_get_config("zquest","rulesetdialog",1);
25816 5 EnableTooltips = zc_get_config("zquest","enable_tooltips",1);
25817 5 TooltipsHighlight = zc_get_config("zquest","ttip_highlight",1);
25818 5 tooltip_maxtimer = vbound(zc_get_config("zquest","ttip_timer",30),0,60*60);
25819 5 ShowFFScripts = zc_get_config("zquest","showffscripts",1);
25820 5 ShowSquares = zc_get_config("zquest","showsquares",1);
25821 5 ShowFFCs = zc_get_config("zquest","showffcs",0);
25822 5 ShowInfo = zc_get_config("zquest","showinfo",1);
25823 5 skipLayerWarning = zc_get_config("zquest","skip_layer_warning",0);
25824 5 numericalFlags = zc_get_config("zquest","numerical_flags",0);
25825 5 ViewLayer2BG = zc_get_config("zquest","layer2_bg",0);
25826 5 ViewLayer3BG = zc_get_config("zquest","layer3_bg",0);
25827 5 ActiveLayerHighlight = zc_get_config("zquest","hl_active_lyr",0);
25828
25829 5 OpenLastQuest = zc_get_config("zquest","open_last_quest",0);
25830 5 ShowMisalignments = zc_get_config("zquest","show_misalignments",0);
25831 5 AnimationOn = zc_get_config("zquest","animation_on",1);
25832 5 AutoBackupRetention = zc_get_config("zquest","auto_backup_retention",2);
25833 5 AutoSaveInterval = zc_get_config("zquest","auto_save_interval",6);
25834 5 AutoSaveRetention = zc_get_config("zquest","auto_save_retention",2);
25835 5 UncompressedAutoSaves = zc_get_config("zquest","uncompressed_auto_saves",1);
25836 5 OverwriteProtection = zc_get_config("zquest","overwrite_prevention",0)!=0;
25837 5 ImportMapBias = zc_get_config("zquest","import_map_bias",0);
25838
25839 5 KeyboardRepeatDelay = zc_get_config("zquest","keyboard_repeat_delay",300);
25840 5 KeyboardRepeatRate = zc_get_config("zquest","keyboard_repeat_rate",80);
25841
25842 // Frameskip = zc_get_config("zquest","frameskip",0); //todo: this is not actually supported yet.
25843 5 RequestedFPS = zc_get_config("zquest","fps",60);
25844 5 ForceExit = zc_get_config("zquest","force_exit",0);
25845
25846 // Autofill for Combo Page, Tile Page
25847 5 PreFillTileEditorPage = zc_get_config("zquest","PreFillTileEditorPage",0);
25848 5 PreFillComboEditorPage = zc_get_config("zquest","PreFillComboEditorPage",0);
25849
25850 5 pixeldb = zc_get_config("ZQ_GUI","bottom_8_pixels",0);
25851 5 infobg = zc_get_config("ZQ_GUI","info_text_bg",0);
25852
25853 5 large_merged_combopane = zc_get_config("ZQ_GUI","merge_cpane_large",0);
25854 5 compact_merged_combopane = zc_get_config("ZQ_GUI","merge_cpane_compact",1);
25855
25856 5 compact_square_panels = zc_get_config("ZQ_GUI","square_panels_compact",0);
25857
25858 5 large_zoomed_fav = zc_get_config("ZQ_GUI","zoom_fav_large",0);
25859 5 compact_zoomed_fav = zc_get_config("ZQ_GUI","zoom_fav_compact",1);
25860 5 large_zoomed_cmd = zc_get_config("ZQ_GUI","zoom_cmd_large",1);
25861 5 compact_zoomed_cmd = zc_get_config("ZQ_GUI","zoom_cmd_compact",1);
25862
25863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(zc_get_config("gui","disable_window_resizing",0))
25864 all_set_resize_flag(false);
25865
25866 5 load_hotkeys();
25867
25868 #ifdef _WIN32
25869 zqUseWin32Proc = zc_get_config("zquest","zq_win_proc_fix",0);
25870
25871 #endif
25872
25873
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if(RequestedFPS < 12 || RequestedFPS> 60)
25874 {
25875 RequestedFPS = vbound(RequestedFPS,12,60);
25876 zc_set_config("zquest","fps",RequestedFPS);
25877 }
25878
25879 LOCK_FUNCTION(update_throttle_counter);
25880
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (install_int_ex(update_throttle_counter, BPS_TO_TIMER(60)) < 0)
25881 {
25882 Z_error_fatal("Could not install timer.\n");
25883 }
25884
25885 LOCK_VARIABLE(myvsync);
25886 LOCK_FUNCTION(myvsync_callback);
25887
25888
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(install_int_ex(myvsync_callback,BPS_TO_TIMER(RequestedFPS)))
25889 {
25890 Z_error_fatal("couldn't allocate timer");
25891 }
25892
25893 5 byte layermask = zc_get_config("zquest","layer_mask",0x7F);
25894 5 int32_t usefullscreen = zc_get_config("zquest","fullscreen",0);
25895 5 tempmode = (usefullscreen == 0 ? GFX_AUTODETECT_WINDOWED : GFX_AUTODETECT_FULLSCREEN);
25896
25897
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 5 times.
40 for(int32_t x=0; x<7; x++)
25898 {
25899 35 LayerMaskInt[x]=get_bit(&layermask,x);
25900 35 }
25901
25902 5 DuplicateAction[0] = zc_get_config("zquest","normal_duplicate_action",2);
25903 5 DuplicateAction[1] = zc_get_config("zquest","horizontal_duplicate_action",0);
25904 5 DuplicateAction[2] = zc_get_config("zquest","vertical_duplicate_action",0);
25905 5 DuplicateAction[3] = zc_get_config("zquest","both_duplicate_action",0);
25906 5 LeechUpdate = zc_get_config("zquest","leech_update",500);
25907 5 LeechUpdateTiles = zc_get_config("zquest","leech_update_tiles",1);
25908 5 OnlyCheckNewTilesForDuplicates = zc_get_config("zquest","only_check_new_tiles_for_duplicates",0);
25909 //gui_colorset = zc_get_config("zquest","gui_colorset",0);
25910
25911 5 strcpy(last_timed_save,zc_get_config("zquest","last_timed_save",""));
25912
25913 5 midi_volume = zc_get_config("zquest", "midi", 255);
25914
25915 5 abc_patternmatch = zc_get_config("zquest", "lister_pattern_matching", 1);
25916 5 NoScreenPreview = zc_get_config("zquest", "no_preview", 0);
25917
25918 5 monochrome_console = zc_get_config("CONSOLE","monochrome_debuggers",0)?1:0;
25919
25920 5 try_recovering_missing_scripts = 0;//zc_get_config("Compiler", "try_recovering_missing_scripts",0);
25921 //We need to remove all of the zeldadx refs to the config file for zquest.
25922
25923 5 set_keyboard_rate(KeyboardRepeatDelay,KeyboardRepeatRate);
25924
25925 5 is_compact = zc_get_config("ZQ_GUI","compact_mode",1);
25926 5 mapscreenbmp = nullptr;
25927 5 brushbmp = nullptr;
25928 5 brushscreen = nullptr;
25929 5 screen2 = nullptr;
25930 5 tmp_scr = nullptr;
25931 5 menu1 = nullptr;
25932 5 menu3 = nullptr;
25933
25934
2/2
✓ Branch 0 taken 6300 times.
✓ Branch 1 taken 5 times.
6305 for(int32_t i=0; i<MAXFAVORITECOMBOS; ++i)
25935 {
25936 6300 favorite_combos[i]=-1;
25937 6300 pool_combos[i].clear();
25938 6300 }
25939 5 FavoriteComboPage = 0;
25940 5 pool_dirty = true;
25941
25942
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(used_switch(argc,argv,"-d"))
25943 {
25944 set_debug(!strcmp(zquestpwd,zc_get_config("zquest","debug_this","")));
25945 }
25946
25947 5 zcmusic_init();
25948 5 zcmixer = zcmixer_create();
25949 1077 install_int_ex([](){ zcmusic_poll(); }, MSEC_TO_TIMER(25));
25950
25951 5 set_color_depth(8);
25952
25953 5 set_close_button_callback((void (*)()) hit_close_button);
25954
25955
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(used_switch(argc,argv,"-fullscreen"))
25956 {
25957 tempmode = GFX_AUTODETECT_FULLSCREEN;
25958 }
25959
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 else if(used_switch(argc,argv,"-windowed"))
25960 {
25961 tempmode=GFX_AUTODETECT_WINDOWED;
25962 }
25963
25964 5 zq_screen_w = LARGE_W;
25965 5 zq_screen_h = LARGE_H;
25966 5 window_width = zc_get_config("zquest","window_width",-1);
25967 5 window_height = zc_get_config("zquest","window_height",-1);
25968 5 auto [w, h] = zc_get_default_display_size(LARGE_W, LARGE_H, window_width, window_height);
25969
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 int32_t videofail = is_headless() ? 0 : (set_gfx_mode(tempmode,w,h,zq_screen_w,zq_screen_h));
25970
25971 //extra block here is intentional
25972
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(videofail!=0)
25973 {
25974 quit_game();
25975 allegro_exit();
25976 }
25977
25978 5 zalleg_create_window();
25979 5 Z_message("gfx mode set at -%d %dbpp %d x %d \n",
25980 5 tempmode, get_color_depth(), zq_screen_w, zq_screen_h);
25981
25982 5 set_window_title("ZC Editor");
25983
25984 5 load_size_poses();
25985
25986
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (!is_headless())
25987 {
25988 // Just in case.
25989 while (!all_get_display()) {
25990 al_rest(1);
25991 }
25992
25993 al_resize_display(all_get_display(), w, h);
25994 }
25995
25996
25997 #ifndef __EMSCRIPTEN__
25998
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if (!all_get_fullscreen_flag() && !is_headless()) {
25999 al_resize_display(all_get_display(), w, h);
26000
26001 int window_w = al_get_display_width(all_get_display());
26002 int window_h = al_get_display_height(all_get_display());
26003
26004 int new_x = zc_get_config("zquest","window_x",0);
26005 int new_y = zc_get_config("zquest","window_y",0);
26006 if(zc_get_config("zquest","save_window_position",0) && (new_x || new_y))
26007 {
26008 //load saved position
26009 //already stored in new_x/new_y
26010 }
26011 else
26012 {
26013 //Get default position
26014 ALLEGRO_MONITOR_INFO info;
26015 al_get_monitor_info(0, &info);
26016
26017 int mw = (info.x2 - info.x1);
26018 int mh = (info.y2 - info.y1);
26019 new_x = mw / 2 - window_w / 2;
26020 new_y = mh / 2 - window_h / 2;
26021 //Don't spawn the window too far down (taskbar?)
26022 if(new_y + window_h > mh - 72)
26023 new_y = mh-72-window_h;
26024 }
26025 #ifdef ALLEGRO_MACOSX
26026 if (zc_get_config("zquest","save_window_position",0))
26027 al_set_window_position(all_get_display(), new_x, new_y);
26028 #else
26029 al_set_window_position(all_get_display(), new_x, new_y);
26030 #endif
26031 }
26032 #endif
26033
26034 5 position_mouse(zq_screen_w/2,zq_screen_h/2);
26035
26036 5 dmapbmp_small = create_bitmap_ex(8,65,33);
26037 5 dmapbmp_large = create_bitmap_ex(8,177,81);
26038
26039
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!screen2 || !tmp_scr || !menu1 || !menu3 || !dmapbmp_large || !dmapbmp_large || !brushbmp || !brushscreen)// || !brushshadowbmp )
26040 {
26041 Z_error_fatal("Failed to create system bitmaps!\n");
26042 return 1;
26043 }
26044
26045 5 int quick_assign_arg = used_switch(argc, argv, "-quick-assign");
26046
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
5 if (quick_assign_arg > 0)
26047 {
26048 3 is_zq_replay_test = true;
26049 3 set_headless_mode();
26050
26051 3 int load_ret = load_quest(argv[quick_assign_arg + 1], false);
26052 3 bool success = load_ret == qe_OK;
26053
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (!success)
26054 {
26055 printf("Failed to load quest: %d\n", load_ret);
26056 exit(1);
26057 }
26058
26059 3 success = do_compile_and_slots(1, false);
26060
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (!success)
26061 {
26062 printf("Failed to compile\n");
26063 exit(1);
26064 }
26065
26066 3 success = save_quest(argv[quick_assign_arg + 1], false) == 0;
26067
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (!success)
26068 {
26069 printf("Failed to save quest\n");
26070 exit(1);
26071 }
26072
26073 3 exit(0);
26074 }
26075
26076 2 int export_strings_arg = used_switch(argc, argv, "-export-strings");
26077
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 if (export_strings_arg > 0)
26078 {
26079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (export_strings_arg + 3 > argc)
26080 {
26081 printf("%d\n", argc);
26082 printf("expected -export-strings input.qst output.tsv\n");
26083 exit(1);
26084 }
26085
26086 1 is_zq_replay_test = true;
26087 1 set_headless_mode();
26088
26089 1 int load_ret = load_quest(argv[export_strings_arg + 1], false);
26090 1 bool success = load_ret == qe_OK;
26091
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (!success)
26092 {
26093 printf("Failed to load quest: %d\n", load_ret);
26094 exit(1);
26095 }
26096
26097 1 success = save_strings_tsv(argv[export_strings_arg + 2]);
26098
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (!success)
26099 {
26100 printf("Failed to export strings\n");
26101 exit(1);
26102 }
26103
26104 1 exit(0);
26105 }
26106
26107
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (!is_headless())
26108 {
26109 zc_set_palette((RGB*)zcdata[PAL_ZQUEST].dat);
26110 get_palette(RAMpal);
26111 load_colorset(gui_colorset);
26112 zc_set_palette(RAMpal);
26113 clear_to_color(screen,vc(0));
26114 }
26115
26116 1 zScript = string();
26117 1 strcpy(zScriptBytes, "0 Bytes in Buffer");
26118
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 1 times.
13 for(int32_t i=0; i<MOUSE_BMP_MAX; i++)
26119 {
26120
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 12 times.
60 for(int32_t j=0; j<4; j++)
26121 {
26122 48 mouse_bmp[i][j] = NULL;
26123 48 mouse_bmp_1x[i][j] = NULL;
26124 48 }
26125 12 }
26126 1 load_mice();
26127 1 gui_mouse_focus=0;
26128 1 MouseSprite::set(ZQM_NORMAL);
26129 1 render_zq(); // Ensure the rendering bitmaps are setup.
26130
26131 #ifdef __EMSCRIPTEN__
26132 em_mark_ready_status();
26133 #endif
26134
26135 1 load_icons();
26136
26137 1 bool load_last_timed_save=false;
26138
26139 1 load_recent_quests();
26140 1 refresh_recent_menu();
26141 //clearConsole();
26142
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 if((last_timed_save[0]!=0)&&(exists(last_timed_save)))
26143 {
26144 if(jwin_alert("ZQuest","It appears that ZQuest crashed last time.","Would you like to load the last timed save?",NULL,"&Yes","&No",'y','n',get_zc_font(font_lfont))==1)
26145 {
26146 int32_t ret = load_quest(last_timed_save);
26147
26148 if(ret == qe_OK)
26149 {
26150 strcpy(filepath,last_timed_save);
26151 load_last_timed_save=true;
26152 saved=false;
26153 }
26154 else
26155 {
26156 jwin_alert("Error","Unable to reload the last timed save.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
26157 }
26158 }
26159 }
26160
26161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!load_last_timed_save)
26162 {
26163 1 strcpy(filepath,zc_get_config("zquest",last_quest_name,""));
26164
26165
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(argc>1 && argv[1][0]!='-')
26166 {
26167 int32_t ret = load_quest(argv[1]);
26168
26169 if(ret == qe_OK)
26170 {
26171 first_save=true;
26172 strcpy(filepath,argv[1]);
26173 refresh(rALL);
26174 }
26175 }
26176
2/8
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 else if(OpenLastQuest&&filepath[0]&&exists(filepath)&&!used_switch(argc,argv,"-new"))
26177 {
26178 int32_t ret = load_quest(filepath);
26179
26180 if(ret == qe_OK)
26181 {
26182 first_save=true;
26183 refresh(rALL);
26184 }
26185 else
26186 {
26187 filepath[0]=temppath[0]=0;
26188 first_save=false;
26189 }
26190 }
26191 else
26192 {
26193 1 init_quest();
26194
26195
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(RulesetDialog)
26196 {
26197 PickRuleset();
26198 PickRuleTemplate();
26199 }
26200
26201 //otherwise the blank quest gets the name of the last loaded quest... not good! -DD
26202 1 filepath[0]=temppath[0]=0;
26203 1 first_save=false;
26204 }
26205 1 }
26206
26207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(used_switch(argc,argv,"-q"))
26208 {
26209 1 Z_message("-q switch used, quitting program.\n");
26210 1 exit(0);
26211 }
26212
26213 for(int32_t x=0; x<MAXITEMS; x++)
26214 {
26215 lens_hint_item[x][0]=0;
26216 lens_hint_item[x][1]=0;
26217 }
26218
26219 for(int32_t x=0; x<MAXWPNS; x++)
26220 {
26221 lens_hint_weapon[x][0]=0;
26222 lens_hint_weapon[x][1]=0;
26223 }
26224
26225 load_selections();
26226 load_arrows();
26227 clear_to_color(menu1,vc(0));
26228 DIALOG_PLAYER *player2=init_dialog(dialogs,-1);
26229
26230 get_palette(RAMpal);
26231
26232 rgb_map = &zq_rgb_table;
26233
26234 #ifdef __EMSCRIPTEN__
26235 {
26236 int qs_map = EM_ASM_INT({
26237 return new URL(location.href).searchParams.get('map') ?? -1;
26238 });
26239 int qs_screen = EM_ASM_INT({
26240 return new URL(location.href).searchParams.get('screen') ?? -1;
26241 });
26242 if (qs_map != -1 && qs_screen != -1) {
26243 Map.setCurrMap(qs_map);
26244 Map.setCurrScr(qs_screen);
26245 }
26246 }
26247 #endif
26248
26249 // setup_combo_animations();
26250 pause_refresh = false;
26251 refresh_pal();
26252 refresh(rALL);
26253 for(int q = 0; q < brush_width_menu.size(); ++q)
26254 brush_width_menu.at(q)->select(q==0);
26255 for(int q = 0; q < brush_height_menu.size(); ++q)
26256 brush_height_menu.at(q)->select(q==0);
26257 set_filltype(1);
26258
26259 rebuild_trans_table();
26260
26261 if (!is_headless())
26262 {
26263 set_display_switch_mode(SWITCH_BACKGROUND);
26264 set_display_switch_callback(SWITCH_OUT, switch_out);
26265 set_display_switch_callback(SWITCH_IN, switch_in);
26266 }
26267
26268 if(!update_dialog(player2))
26269 exiting_program = true;
26270 //clear_keybuf();
26271 media_menu.disable_uid(MENUID_MEDIA_CHANGETRACK, true);
26272 disable_hotkey(ZQKEY_CHANGE_TRACK, true);
26273
26274 fix_drawing_mode_menu();
26275
26276
26277 #ifdef _WIN32
26278
26279 if(zqUseWin32Proc != FALSE)
26280 {
26281 al_trace("Config file warning: \"zq_win_proc_fix\" enabled switch found. This can cause crashes on some computers.\n");
26282 win32data.zqSetDefaultThreadPriority(0);
26283 win32data.zqSetCustomCallbackProc(al_get_win_window_handle(all_get_display()));
26284 }
26285
26286 #endif
26287
26288 time(&auto_save_time_start);
26289
26290 FFCore.init();
26291 ZQincludePaths = FFCore.includePaths;
26292
26293 Map.setCopyFFC(-1); //Do not have an initial ffc on the clipboard.
26294 brush_menu.select_uid(MENUID_BRUSH_AUTOBRUSH, AutoBrush);
26295 brush_menu.disable_uid(MENUID_BRUSH_WIDTH, AutoBrush);
26296 brush_menu.disable_uid(MENUID_BRUSH_HEIGHT, AutoBrush);
26297 brush_menu.select_uid(MENUID_BRUSH_COMBOBRUSH, ComboBrush);
26298 brush_menu.select_uid(MENUID_BRUSH_FLOATBRUSH, FloatBrush);
26299
26300 init_ffpos();
26301
26302 call_foo_dlg();
26303
26304 while(!exiting_program)
26305 {
26306 #ifdef _WIN32
26307 if(zqUseWin32Proc != FALSE)
26308 win32data.Update(Frameskip); //experimental win32 fixes
26309 #endif
26310 check_autosave();
26311 ++alignment_arrow_timer;
26312
26313 if(alignment_arrow_timer>63)
26314 {
26315 alignment_arrow_timer=0;
26316 }
26317
26318 file_menu.disable_uid(MENUID_FILE_SAVE, saved||disable_saving||OverwriteProtection);
26319 file_menu.disable_uid(MENUID_FILE_REVERT, saved||disable_saving||OverwriteProtection);
26320 file_menu.disable_uid(MENUID_FILE_SAVEAS, disable_saving);
26321
26322 fixtools_menu.disable_uid(MENUID_FIXTOOL_OLDSTRING,
26323 !(get_qr(qr_OLD_STRING_EDITOR_MARGINS)
26324 ||get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)));
26325
26326 edit_menu.disable_uid(MENUID_EDIT_UNDO, !Map.CanUndo());
26327 edit_menu.disable_uid(MENUID_EDIT_REDO, !Map.CanRedo());
26328
26329 bool canpaste = Map.CanPaste();
26330 edit_menu.disable_uid(MENUID_EDIT_PASTE, !canpaste);
26331 edit_menu.disable_uid(MENUID_EDIT_PASTEALL, !canpaste);
26332 edit_menu.disable_uid(MENUID_EDIT_ADVPASTE, !canpaste);
26333 edit_menu.disable_uid(MENUID_EDIT_SPECPASTE, !canpaste);
26334 rc_menu_screen.disable_uid(MENUID_RCSCREEN_PASTE, !canpaste);
26335 rc_menu_screen.disable_uid(MENUID_RCSCREEN_ADVPASTE, !canpaste);
26336 rc_menu_screen.disable_uid(MENUID_RCSCREEN_SPECPASTE, !canpaste);
26337 for(MenuItem& mit : paste_menu.inner())
26338 mit.disable(!canpaste);
26339 for(MenuItem& mit : paste_item_menu.inner())
26340 mit.disable(!canpaste);
26341
26342 edit_menu.disable_uid(MENUID_EDIT_COPY, !(Map.CurrScr()->valid&mVALID));
26343 edit_menu.disable_uid(MENUID_EDIT_DELETE, !(Map.CurrScr()->valid&mVALID));
26344
26345 // Are some things selected?
26346 view_menu.select_uid(MENUID_VIEW_WALKABILITY, Flags&cWALK);
26347 view_menu.select_uid(MENUID_VIEW_FLAGS, Flags&cFLAGS);
26348 view_menu.select_uid(MENUID_VIEW_CSET, Flags&cCSET);
26349 view_menu.select_uid(MENUID_VIEW_TYPES, Flags&cCTYPE);
26350 view_menu.select_uid(MENUID_VIEW_INFO, ShowInfo);
26351 view_menu.select_uid(MENUID_VIEW_SQUARES, ShowSquares);
26352 view_menu.select_uid(MENUID_VIEW_FFCS, ShowFFCs);
26353 view_menu.select_uid(MENUID_VIEW_SCRIPTNAMES, ShowFFScripts);
26354 view_menu.select_uid(MENUID_VIEW_GRID, ShowGrid);
26355 view_menu.select_uid(MENUID_VIEW_DARKNESS, get_qr(qr_NEW_DARKROOM) && (Flags&cNEWDARK));
26356 view_menu.select_uid(MENUID_VIEW_L2BG, ViewLayer2BG);
26357 view_menu.select_uid(MENUID_VIEW_L3BG, ViewLayer3BG);
26358 view_menu.select_uid(MENUID_VIEW_LAYERHIGHLIGHT, ActiveLayerHighlight);
26359
26360 maps_menu.disable_uid(MENUID_MAPS_NEXT, !map_count || Map.getCurrMap() >= map_count);
26361 maps_menu.disable_uid(MENUID_MAPS_PREV, Map.getCurrMap()<=0);
26362
26363 etc_menu.disable_uid(MENUID_ETC_VIDMODE, isFullScreen()==1);
26364 etc_menu.select_uid(MENUID_ETC_FULLSCREEN, isFullScreen()==1);
26365
26366 if(!update_dialog(player2))
26367 exiting_program = true;
26368
26369 //clear_keybuf();
26370 handle_close_btn_quit();
26371 }
26372 parser_console.kill();
26373 killConsole();
26374
26375 quit_game();
26376
26377 if(ForceExit) //last resort fix to the allegro process hanging bug.
26378 exit(0);
26379
26380 return 0;
26381 // memset(qtpathtitle,0,10);//UNREACHABLE
26382 }
26383 END_OF_MAIN()
26384
26385 35 void init_bitmap(BITMAP** bmp, int32_t w, int32_t h)
26386 {
26387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(*bmp)
26388 destroy_bitmap(*bmp);
26389 35 *bmp = create_bitmap_ex(8,w,h);
26390 35 clear_bitmap(*bmp);
26391 35 }
26392 5 void load_size_poses()
26393 {
26394 5 ttip_uninstall_all();
26395
26396 5 FONT* favcmdfont = get_custom_font(CFONT_FAVCMD);
26397 5 FONT* guifont = get_custom_font(CFONT_GUI);
26398
26399 5 d_nbmenu_proc(MSG_START, &dialogs[0], 0);
26400
26401 5 commands_list.xscale = command_buttonwidth;
26402 5 commands_list.yscale = 10+text_height(favcmdfont);
26403
26404 5 auto drawmode_wid = 64;
26405
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 5 times.
35 for(auto q = 0; q < dm_max; ++q)
26406 {
26407 30 auto wid = text_length(guifont, dm_names[q]);
26408
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(wid > drawmode_wid)
26409 drawmode_wid = wid;
26410 30 }
26411
26412 //Main GUI objects
26413
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(is_compact)
26414 {
26415 5 num_combo_cols = 2;
26416 5 combo_col_scale = 16;
26417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(compact_merged_combopane)
26418 {
26419 5 num_combo_cols = 1;
26420 5 combo_col_scale = 32;
26421 5 }
26422
26423 5 mapscreen_x=0;
26424 5 mapscreen_y=dialogs[0].h;
26425 5 mapscreensize=3;
26426 5 showedges=0;
26427 5 showallpanels=0;
26428
26429 5 blackout_color=8;
26430
26431 5 auto mapscr_wid = (((showedges?2:0)+16)*16*mapscreensize);
26432 5 combolist_window.w=zq_screen_w-mapscr_wid;
26433 5 combolist_window.x=zq_screen_w-combolist_window.w;
26434
26435 5 favorites_window.x=combolist_window.x;
26436 5 favorites_window.w=combolist_window.w;
26437 5 favorites_window.h=136;
26438 5 favorites_window.y=zq_screen_h-favorites_window.h;
26439
26440 5 combolist_window.y=0;
26441 5 combolist_window.h=favorites_window.y-combolist_window.y;
26442
26443 5 combo_preview.x=zq_screen_w-32-8;
26444 5 combo_preview.y=combolist_window.y+6;
26445 5 combo_preview.w=32;
26446 5 combo_preview.h=32;
26447 5 combo_preview2.clear();
26448
26449 5 auto col_wid = 4*combo_col_scale;
26450 5 auto cols_wid = col_wid * num_combo_cols;
26451 5 auto cols_spacing = (combolist_window.w-cols_wid)/(num_combo_cols+1);
26452
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
10 for(auto q = 0; q < num_combo_cols; ++q)
26453 {
26454 5 combolist[q].x=combolist_window.x+(cols_spacing*(q+1))+(col_wid*q);
26455 5 combolist[q].y=combolist_window.y+54;
26456 5 combolist[q].w=4;
26457 5 combolist[q].h=compact_merged_combopane ? 15 : 30;
26458 5 combolist[q].xscale = combo_col_scale;
26459 5 combolist[q].yscale = combo_col_scale;
26460
26461 5 comboaliaslist[q].x = combolist[q].x;
26462 5 comboaliaslist[q].y = combolist[q].y;
26463 5 comboaliaslist[q].w = 4;
26464 5 comboaliaslist[q].h = compact_merged_combopane ? 13 : 26;
26465 5 comboaliaslist[q].xscale = combo_col_scale;
26466 5 comboaliaslist[q].yscale = combo_col_scale;
26467
26468 5 combolistscrollers[q].w=2;
26469 5 combolistscrollers[q].h=1;
26470 5 combolistscrollers[q].xscale=11;
26471 5 combolistscrollers[q].yscale=11;
26472 5 combolistscrollers[q].x=combolist[q].x+(combolist[q].w*combolist[q].xscale/2)-11;
26473 5 combolistscrollers[q].y=combolist[q].y-combolistscrollers[q].th()-3;
26474 5 }
26475
26476 5 comboalias_preview.x=zq_screen_w-((combolist_window.w+64)/2);
26477 5 comboalias_preview.h=64;
26478 5 comboalias_preview.y=favorites_window.y-comboalias_preview.h-8;
26479 5 comboalias_preview.w=64;
26480
26481 5 combo_merge_btn.w = 20;
26482 5 combo_merge_btn.h = 20;
26483 5 combo_merge_btn.x = zq_screen_w-(combolist_window.w+combo_merge_btn.w)/2;
26484 5 combo_merge_btn.y = combolist[0].y-combo_merge_btn.h;
26485
26486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(num_combo_cols == 1)
26487 {
26488 5 combolistscrollers[0].x += 34;
26489 5 }
26490 5 drawmode_btn.x = combolist_window.x-drawmode_wid;
26491 5 drawmode_btn.y = 0;
26492 5 drawmode_btn.w = drawmode_wid;
26493 5 drawmode_btn.h = mapscreen_y;
26494
26495 5 compactbtn.w = text_length(guifont,"> Compact")+10;
26496 5 compactbtn.x = drawmode_btn.x-compactbtn.w;
26497 5 compactbtn.y = drawmode_btn.y;
26498 5 compactbtn.h = drawmode_btn.h;
26499
26500
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 5 times.
50 for(int32_t i=0; i<=8; i++)
26501 {
26502 45 map_page_bar[i].w = 48;
26503 45 map_page_bar[i].x = mapscreen_x+(i*48);
26504 45 map_page_bar[i].y = mapscreen_y+(11*16*mapscreensize);
26505 45 map_page_bar[i].h = text_height(guifont)+12;
26506 45 }
26507
26508 5 minimap.w=7+48*3;
26509 5 minimap.h=16+27*3;
26510
26511 5 layer_panel.x=map_page_bar[6].x;
26512 5 layer_panel.y=map_page_bar[0].y;
26513 5 layer_panel.w=combolist_window.x - layer_panel.x;
26514 5 layer_panel.h=map_page_bar[0].h;
26515 5 layerpanel_buttonwidth = 51;
26516 5 layerpanel_buttonheight = layer_panel.h;
26517 5 layerpanel_checkbox_hei = layerpanel_buttonheight-4;
26518 5 layerpanel_checkbox_wid = 15;
26519
26520 5 minimap.x=3;
26521 5 minimap.y=layer_panel.y+layer_panel.h+4;
26522
26523 5 real_minimap.x = minimap.x+3;
26524 5 real_minimap.y = minimap.y+5;
26525 5 real_minimap.w = 16;
26526 5 real_minimap.h = 9;
26527 5 real_minimap.xscale = 9;
26528 5 real_minimap.yscale = 9;
26529 5 real_minimap.fw = real_minimap.xscale*8;
26530 5 real_minimap.fh = real_minimap.yscale*8;
26531
26532 5 int upscale_mm = 3;
26533 5 int xwid = real_minimap.tw()*(upscale_mm-1);
26534 5 int xhei = real_minimap.th()*(upscale_mm-1);
26535 5 minimap_zoomed.set(minimap.x, minimap.y-xhei, minimap.w+xwid, minimap.h+xhei+4);
26536 5 real_minimap_zoomed.set(minimap_zoomed.x+3, minimap_zoomed.y+5, real_minimap.w, real_minimap.h, real_minimap.xscale*upscale_mm, real_minimap.yscale*upscale_mm);
26537 5 real_minimap_zoomed.fw = real_minimap_zoomed.xscale*8;
26538 5 real_minimap_zoomed.fh = real_minimap_zoomed.yscale*8;
26539
26540 5 screrrorpos.x = combolist_window.x - 3;
26541 5 screrrorpos.y = layer_panel.y - 16;
26542
26543 5 mouse_scroll_h=10;
26544
26545 5 favorites_list.x=favorites_window.x+8;
26546 5 favorites_list.y=favorites_window.y+16;
26547 5 favorites_list.xscale = 16;
26548 5 favorites_list.yscale = 16;
26549 5 favorites_list.w=(favorites_window.w-16)/favorites_list.xscale;
26550 5 favorites_list.h=(favorites_window.h-24)/favorites_list.yscale;
26551
26552 5 commands_list.w=4;
26553
26554 5 int bh = commands_list.yscale;
26555 5 int bw = 26;
26556 5 commands_window.w=commands_list.w*commands_list.xscale+10+bw;
26557 5 commands_window.x=combolist_window.x-commands_window.w;
26558 5 commands_window.y=layer_panel.y+layer_panel.h;
26559 5 commands_window.h=zq_screen_h-commands_window.y;
26560 5 int bx = commands_window.x+2;
26561
26562 5 commands_list.y=commands_window.y+4;
26563 5 commands_list.h=(zq_screen_h - commands_list.y) / commands_list.yscale;
26564 5 commands_list.x=bx+bw;
26565
26566 5 commands_zoombtn.w = bw;
26567 5 commands_zoombtn.h = bh;
26568 5 commands_zoombtn.x = bx;
26569 5 commands_zoombtn.y = commands_list.y;
26570
26571 5 commands_infobtn.w = bw;
26572 5 commands_infobtn.h = bh;
26573 5 commands_infobtn.x = bx;
26574 5 commands_infobtn.y = commands_zoombtn.y + commands_infobtn.h;
26575
26576 5 commands_x.w = bw;
26577 5 commands_x.h = bh;
26578 5 commands_x.x = bx;
26579 5 commands_x.y = commands_infobtn.y + commands_x.h;
26580
26581 5 commands_txt.clear();
26582
26583 5 main_panel.x = 0;
26584 5 main_panel.y = layer_panel.y+layer_panel.h;
26585 5 main_panel.w = commands_window.x - main_panel.x;
26586 5 main_panel.h = 76+32;
26587 5 preview_panel = main_panel;
26588 5 preview_panel.x = 0;
26589 5 preview_panel.w = commands_window.x - preview_panel.x;
26590
26591 5 preview_text.x = preview_panel.x+3;
26592 5 preview_text.y = preview_panel.y+3;
26593 5 preview_text.w = 2;
26594 5 preview_text.h = 6;
26595 5 preview_text.xscale = 10;
26596 5 preview_text.yscale = text_height(get_zc_font(font_lfont_l));
26597
26598 5 panel_align = 1;
26599 5 int swapbtnw = 32, swapbtnh = 20;
26600 5 int swapbtnx = main_panel.x+main_panel.tw()-swapbtnw;
26601 5 squarepanel_swap_btn.set(swapbtnx, zq_screen_h-swapbtnh, swapbtnw, swapbtnh);
26602
26603 5 int sqx = minimap.x+minimap.tw();
26604 5 squares_panel.set(sqx,main_panel.y,main_panel.tw()-sqx,main_panel.th());
26605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(compact_square_panels)
26606 {
26607 int cmpy = main_panel.y+(main_panel.th()/2);
26608 squarepanel_up_btn.set(swapbtnx, cmpy-swapbtnh, swapbtnw, swapbtnh);
26609 squarepanel_down_btn.set(swapbtnx, cmpy, swapbtnw, swapbtnh);
26610
26611 txtoffs_single.x = 18;
26612 txtoffs_single.y = 36;
26613 txtoffs_double_1.x = 18;
26614 txtoffs_double_1.y = 36;
26615 txtoffs_double_2.x = 18;
26616 txtoffs_double_2.y = 36 + text_height(get_custom_font(CFONT_GUI));
26617
26618 //Clear them all- if they stay cleared, they are invisible.
26619 itemsqr_pos.clear();
26620 stairsqr_pos.clear();
26621 warparrival_pos.clear();
26622 flagsqr_pos.clear();
26623 enemy_prev_pos.clear();
26624 for(int q = 0; q < 4; ++q)
26625 warpret_pos[q].clear();
26626
26627 int sqr_x1 = sqx+12;
26628 int sqr_y1 = main_panel.y+12;
26629 int sqr_xoffs = (16*2)+4 + 12;
26630 switch(compact_active_panel)
26631 {
26632 case 0: //Warp Squares
26633 {
26634 int x = sqr_x1;
26635 for(int q = 0; q < 4; ++q)
26636 {
26637 warpret_pos[q].set(x,sqr_y1,(16*2)+4,(16*2)+4);
26638 x += sqr_xoffs;
26639 }
26640 break;
26641 }
26642 case 1: //Other Squares
26643 {
26644 itemsqr_pos.set(sqr_x1+(sqr_xoffs*0), sqr_y1, (16*2)+4,(16*2)+4);
26645 stairsqr_pos.set(sqr_x1+(sqr_xoffs*1), sqr_y1, (16*2)+4,(16*2)+4);
26646 warparrival_pos.set(sqr_x1+(sqr_xoffs*2), sqr_y1, (16*2)+4,(16*2)+4);
26647 flagsqr_pos.set(sqr_x1+(sqr_xoffs*3), sqr_y1, (16*2)+4,(16*2)+4);
26648 break;
26649 }
26650 case 2: //Enemy Preview
26651 {
26652 enemy_prev_pos.set(sqr_x1, sqr_y1, 5, 2, 32, 32);
26653 break;
26654 }
26655 }
26656 }
26657 else
26658 {
26659 5 squarepanel_up_btn.clear();
26660 5 squarepanel_down_btn.clear();
26661 5 txtoffs_single.x = 10;
26662 5 txtoffs_single.y = 22;
26663 5 txtoffs_double_1.x = 10;
26664 5 txtoffs_double_1.y = 22;
26665 5 txtoffs_double_2.x = 10;
26666 5 txtoffs_double_2.y = 30;
26667
26668
26669 5 int sqr_x1 = sqx+24;
26670 5 int sqr_y1 = main_panel.y+12;
26671 5 int sqr_y2 = sqr_y1+42;
26672 5 int sqr_xdist = 32;
26673 5 itemsqr_pos.set(sqr_x1+(sqr_xdist*0),sqr_y1,20,20);
26674 5 stairsqr_pos.set(sqr_x1+(sqr_xdist*1),sqr_y1,20,20);
26675 5 warparrival_pos.set(sqr_x1+(sqr_xdist*2),sqr_y1,20,20);
26676 5 flagsqr_pos.set(sqr_x1+(sqr_xdist*3),sqr_y1,20,20);
26677
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 5 times.
25 for(auto q = 0; q < 4; ++q)
26678 {
26679 20 warpret_pos[q].set(sqr_x1+(sqr_xdist*q),sqr_y2,20,20);
26680 20 }
26681 5 enemy_prev_pos.set(sqr_x1+(sqr_xdist*4), sqr_y1, 4, 3, 16, 16);
26682 5 enemy_prev_pos.fw = enemy_prev_pos.xscale*2;
26683 5 enemy_prev_pos.fh = enemy_prev_pos.yscale*2;
26684 }
26685
26686 5 auto& last_alias_list = comboaliaslist[num_combo_cols-1];
26687 5 combopool_preview.x=comboaliaslist[0].x;
26688 5 combopool_preview.y=last_alias_list.y+(last_alias_list.h*last_alias_list.yscale)+16;
26689 5 combopool_preview.w=(last_alias_list.x+(last_alias_list.w*last_alias_list.xscale))-comboaliaslist[0].x;
26690 5 combopool_preview.h=zq_screen_h-8-combopool_preview.y;
26691 5 combopool_preview.w -= combopool_preview.w%16;
26692 5 combopool_preview.h -= combopool_preview.h%16;
26693
26694 5 FONT* tfont = get_zc_font(font_lfont_l);
26695 5 combopool_prevbtn.w = text_length(tfont, "Unweighted")+10;
26696 5 combopool_prevbtn.h = 11;
26697 5 combopool_prevbtn.x = combopool_preview.x;
26698 5 combopool_prevbtn.y = combopool_preview.y-combopool_prevbtn.h;
26699
26700 5 mappage_count = 6;
26701
26702 5 txfont = get_zc_font(font_lfont_l);
26703 5 combo_preview_text1.set(combo_preview.x-5,combo_preview.y,1,3,1,text_height(txfont));
26704 5 combo_preview_text2.clear();
26705
26706 5 favorites_x.w = 17;
26707 5 favorites_infobtn.w = 17;
26708 5 favorites_zoombtn.w = 17;
26709 5 favorites_pgleft.w = 17;
26710 5 favorites_pgright.w = 17;
26711 5 }
26712 else
26713 {
26714 num_combo_cols = 4;
26715 combo_col_scale = 16;
26716 if(large_merged_combopane)
26717 {
26718 num_combo_cols = 2;
26719 combo_col_scale = 32;
26720 }
26721
26722 mapscreen_x=0;
26723 mapscreen_y=dialogs[0].h;
26724 mapscreensize=2;
26725 showedges=1;
26726 showallpanels=0;
26727
26728 blackout_color=8;
26729
26730 favorites_window.h=136;
26731 favorites_window.y=zq_screen_h-favorites_window.h;
26732
26733 auto mapscr_wid = (((showedges?2:0)+16)*16*mapscreensize);
26734 combolist_window.w=zq_screen_w-mapscr_wid;
26735 combolist_window.x=zq_screen_w-combolist_window.w;
26736 combolist_window.y=0;
26737 combolist_window.h=favorites_window.y-combolist_window.y;
26738
26739 favorites_window.x=combolist_window.x;
26740 favorites_window.w=combolist_window.w;
26741
26742 combo_preview.x=(zq_screen_w-(combolist_window.w/2))-40;
26743 combo_preview.y=combolist_window.y+6;
26744 combo_preview.w=32;
26745 combo_preview.h=32;
26746 combo_preview2 = combo_preview;
26747 combo_preview2.x += 48;
26748
26749 auto col_wid = 4*combo_col_scale;
26750 auto cols_wid = col_wid * num_combo_cols;
26751 auto cols_spacing = (combolist_window.w-cols_wid)/(num_combo_cols+1);
26752 for(auto q = 0; q < num_combo_cols; ++q)
26753 {
26754 combolist[q].x=combolist_window.x+(cols_spacing*(q+1))+(col_wid*q);
26755 combolist[q].y=combolist_window.y+60;
26756 combolist[q].w=4;
26757 combolist[q].h=large_merged_combopane ? 15 : 30;
26758 combolist[q].xscale = combo_col_scale;
26759 combolist[q].yscale = combo_col_scale;
26760
26761 comboaliaslist[q].x=combolist[q].x;
26762 comboaliaslist[q].y=combolist[q].y;
26763 comboaliaslist[q].w=4;
26764 comboaliaslist[q].h=large_merged_combopane ? 12 : 25;
26765 comboaliaslist[q].xscale = combo_col_scale;
26766 comboaliaslist[q].yscale = combo_col_scale;
26767
26768 combolistscrollers[q].w=2;
26769 combolistscrollers[q].h=1;
26770 combolistscrollers[q].xscale=11;
26771 combolistscrollers[q].yscale=11;
26772 combolistscrollers[q].x=combolist[q].x+(combolist[q].w*combolist[q].xscale/2)-11;
26773 combolistscrollers[q].y=combolist[q].y-combolistscrollers[q].th()-2;
26774 }
26775
26776 comboalias_preview.x=zq_screen_w-((combolist_window.w+64)/2);
26777 comboalias_preview.h=64;
26778 comboalias_preview.w=64;
26779 comboalias_preview.y=favorites_window.y-comboalias_preview.h-8;
26780
26781 combo_merge_btn.w = 20;
26782 combo_merge_btn.h = 20;
26783 combo_merge_btn.x = zq_screen_w-(combolist_window.w+combo_merge_btn.w)/2;
26784 combo_merge_btn.y = combolist[0].y-combo_merge_btn.h;
26785 squarepanel_swap_btn.clear();
26786 squarepanel_up_btn.clear();
26787 squarepanel_down_btn.clear();
26788
26789 drawmode_btn.x = combolist_window.x-drawmode_wid;
26790 drawmode_btn.y = 0;
26791 drawmode_btn.w = drawmode_wid;
26792 drawmode_btn.h = mapscreen_y;
26793
26794 compactbtn.w = text_length(guifont,"> Compact")+10;
26795 compactbtn.x = drawmode_btn.x-compactbtn.w;
26796 compactbtn.y = drawmode_btn.y;
26797 compactbtn.h = drawmode_btn.h;
26798
26799 for(int32_t i=0; i<=8; i++)
26800 {
26801 map_page_bar[i].x = mapscreen_x+(i*16*2*mapscreensize);
26802 map_page_bar[i].y = mapscreen_y+((showedges?13:11)*16*mapscreensize);
26803 map_page_bar[i].w = 64;
26804 map_page_bar[i].h = text_height(guifont)+12;
26805 }
26806
26807 minimap.w=7+48*3;
26808 minimap.h=16+27*3;
26809
26810 layer_panel.x=map_page_bar[0].x;
26811 layer_panel.y=map_page_bar[0].y+map_page_bar[0].h;
26812 layer_panel.w=map_page_bar[8].x+map_page_bar[8].w;
26813 layer_panel.h=text_height(guifont)+8;
26814 layerpanel_buttonwidth = 58;
26815 layerpanel_buttonheight = layer_panel.h;
26816 layerpanel_checkbox_hei = layerpanel_buttonheight-4;
26817 layerpanel_checkbox_wid = 14;
26818
26819 commands_list.w=4;
26820 commands_window.w=commands_list.w*commands_list.xscale+16;
26821 commands_window.x=combolist_window.x-commands_window.w;
26822 commands_window.y=layer_panel.y+layer_panel.h;
26823 commands_window.h=zq_screen_h-commands_window.y;
26824
26825 //buttons panel
26826 main_panel.x = 0;
26827 main_panel.y = layer_panel.y+layer_panel.h;
26828 main_panel.w = commands_window.x - main_panel.x;
26829 main_panel.h = zq_screen_h - main_panel.y;
26830 preview_panel = main_panel;
26831
26832 preview_text.x = preview_panel.x+3;
26833 preview_text.y = preview_panel.y+3;
26834 preview_text.w = 1;
26835 preview_text.h = 12;
26836 preview_text.xscale = 10;
26837 preview_text.yscale = text_height(get_zc_font(font_lfont_l));
26838
26839 minimap.x=3;
26840 minimap.y=main_panel.y+4;
26841
26842 real_minimap.x = minimap.x+3;
26843 real_minimap.y = minimap.y+5;
26844 real_minimap.w = 16;
26845 real_minimap.h = 9;
26846 real_minimap.xscale = 9;
26847 real_minimap.yscale = 9;
26848 real_minimap.fw = real_minimap.xscale*8;
26849 real_minimap.fh = real_minimap.yscale*8;
26850
26851 int upscale_mm = 4;
26852 int xwid = real_minimap.tw()*(upscale_mm-1);
26853 int xhei = real_minimap.th()*(upscale_mm-1);
26854 int zh = minimap.h+xhei+4;
26855 minimap_zoomed.set(minimap.x, zq_screen_h-zh, minimap.w+xwid, zh);
26856 real_minimap_zoomed.set(minimap_zoomed.x+3, minimap_zoomed.y+5, real_minimap.w, real_minimap.h, real_minimap.xscale*upscale_mm, real_minimap.yscale*upscale_mm);
26857 real_minimap_zoomed.fw = real_minimap_zoomed.xscale*8;
26858 real_minimap_zoomed.fh = real_minimap_zoomed.yscale*8;
26859
26860 screrrorpos.x = 575;
26861 screrrorpos.y = 388;
26862
26863 mouse_scroll_h=10;
26864
26865 favorites_list.x=favorites_window.x+8;
26866 favorites_list.y=favorites_window.y+16;
26867 favorites_list.xscale = 16;
26868 favorites_list.yscale = 16;
26869 favorites_list.w=(favorites_window.w-16)/favorites_list.xscale;
26870 favorites_list.h=(favorites_window.h-24)/favorites_list.yscale;
26871
26872 int bh = 16;
26873 int by = commands_window.y+4;
26874 commands_list.y=by+bh;
26875 commands_list.h=(zq_screen_h - commands_list.y) / commands_list.yscale;
26876 commands_list.x=commands_window.x+8;
26877
26878 commands_x.w = 20;
26879 commands_x.h = bh;
26880 commands_x.x = commands_list.x + commands_list.tw() - commands_x.w;
26881 commands_x.y = by;
26882
26883 commands_infobtn.w = 20;
26884 commands_infobtn.h = bh;
26885 commands_infobtn.x = commands_x.x - commands_infobtn.w;
26886 commands_infobtn.y = by;
26887
26888 commands_zoombtn.w = 20;
26889 commands_zoombtn.h = bh;
26890 commands_zoombtn.x = commands_infobtn.x - commands_zoombtn.w;
26891 commands_zoombtn.y = by;
26892
26893 commands_txt.x = commands_list.x;
26894 commands_txt.y = by+(bh-text_height(get_zc_font(font_lfont_l)))/2;
26895
26896 favorites_x.x = favorites_window.x + favorites_window.w - favorites_x.w - 2;
26897 favorites_x.y = favorites_list.y-15;
26898
26899 favorites_infobtn.x = favorites_x.x - favorites_infobtn.w;
26900 favorites_infobtn.y = favorites_x.y;
26901
26902 favorites_zoombtn.x = favorites_infobtn.x - favorites_zoombtn.w;
26903 favorites_zoombtn.y = favorites_infobtn.y;
26904
26905 favorites_pgright.x = favorites_zoombtn.x - favorites_pgright.w;
26906 favorites_pgright.y = favorites_zoombtn.y;
26907
26908 favorites_pgleft.x = favorites_pgright.x - favorites_pgleft.w;
26909 favorites_pgleft.y = favorites_pgleft.y;
26910
26911 txtoffs_single.x = 22;
26912 txtoffs_single.y = 6;
26913 txtoffs_double_1.x = 22;
26914 txtoffs_double_1.y = 2;
26915 txtoffs_double_2.x = 22;
26916 txtoffs_double_2.y = 10;
26917 panel_align = 0;
26918
26919 int sqx = minimap.x+minimap.tw();
26920 squares_panel.set(sqx,main_panel.y,main_panel.tw()-sqx,main_panel.th());
26921 int x2 = sqx+4;
26922 int x1 = x2 - (20+(8*3)+2);
26923 int y1 = main_panel.y+10;
26924 int sw = 20, sh = 20;
26925 int offs = sh+4;
26926
26927 itemsqr_pos.set(x2,y1+(0*offs),sw,sh);
26928 flagsqr_pos.set(x2,y1+(1*offs),sw,sh);
26929 stairsqr_pos.set(x2,y1+(2*offs),sw,sh);
26930 warparrival_pos.set(x2,y1+(6*offs),sw,sh);
26931
26932 enemy_prev_pos.x = main_panel.x+14;
26933 enemy_prev_pos.y = main_panel.y+12 + minimap.h;
26934 enemy_prev_pos.w = 4;
26935 enemy_prev_pos.h = 3;
26936 enemy_prev_pos.xscale = 16;
26937 enemy_prev_pos.yscale = 16;
26938 enemy_prev_pos.fw = enemy_prev_pos.xscale*2;
26939 enemy_prev_pos.fh = enemy_prev_pos.yscale*2;
26940
26941 warpret_pos[0].set(x1,y1+(4*offs),sw,sh);
26942 warpret_pos[1].set(x1,y1+(5*offs),sw,sh);
26943 warpret_pos[2].set(x2,y1+(4*offs),sw,sh);
26944 warpret_pos[3].set(x2,y1+(5*offs),sw,sh);
26945
26946 auto& last_alias_list = comboaliaslist[num_combo_cols-1];
26947 combopool_preview.x=comboaliaslist[0].x;
26948 combopool_preview.y=last_alias_list.y+(last_alias_list.h*last_alias_list.yscale)+16;
26949 combopool_preview.w=(last_alias_list.x+(last_alias_list.w*last_alias_list.xscale))-comboaliaslist[0].x;
26950 combopool_preview.h=(favorites_window.y-combopool_preview.y);//+favorites_window.h-10;
26951 combopool_preview.w -= combopool_preview.w%16;
26952 combopool_preview.h -= combopool_preview.h%16;
26953
26954 FONT* tfont = get_zc_font(font_lfont_l);
26955 combopool_prevbtn.w = text_length(tfont, "Unweighted")+10;
26956 combopool_prevbtn.h = 11;
26957 combopool_prevbtn.x = combopool_preview.x;
26958 combopool_prevbtn.y = combopool_preview.y-combopool_prevbtn.h;
26959
26960 mappage_count = 9;
26961
26962 txfont = get_zc_font(font_lfont_l);
26963 combo_preview_text1.set(combo_preview.x-9,combo_preview.y,1,3,1,text_height(txfont));
26964 combo_preview_text2.set(combo_preview2.x+combo_preview2.w+8,combo_preview2.y,1,3,1,text_height(txfont));
26965
26966 favorites_x.w = 30;
26967 favorites_infobtn.w = 30;
26968 favorites_zoombtn.w = 30;
26969 favorites_pgleft.w = 30;
26970 favorites_pgright.w = 30;
26971 }
26972 //Same in all modes
26973 {
26974
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if(is_compact ? compact_zoomed_cmd : large_zoomed_cmd)
26975 {
26976 5 commands_list.w /= 2;
26977 5 commands_list.xscale *= 2;
26978 5 }
26979
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if(is_compact ? compact_zoomed_fav : large_zoomed_fav)
26980 {
26981
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(favorites_list.w%2)
26982 favorites_list.x += (favorites_list.xscale / 2);
26983 5 favorites_list.xscale *= 2;
26984 5 favorites_list.yscale *= 2;
26985 5 favorites_list.w /= 2;
26986 5 favorites_list.h /= 2;
26987 5 }
26988
26989 5 favorites_x.h = 14;
26990 5 favorites_x.x = favorites_window.x + favorites_window.w - favorites_x.w - 2;
26991 5 favorites_x.y = favorites_list.y-15;
26992
26993 5 favorites_infobtn.h = favorites_x.h;
26994 5 favorites_infobtn.x = favorites_x.x - favorites_infobtn.w;
26995 5 favorites_infobtn.y = favorites_x.y;
26996
26997 5 favorites_zoombtn.h = favorites_infobtn.h;
26998 5 favorites_zoombtn.x = favorites_infobtn.x - favorites_zoombtn.w;
26999 5 favorites_zoombtn.y = favorites_infobtn.y;
27000
27001 5 favorites_pgright.h = favorites_zoombtn.h;
27002 5 favorites_pgright.x = favorites_zoombtn.x - favorites_pgright.w;
27003 5 favorites_pgright.y = favorites_zoombtn.y;
27004
27005 5 favorites_pgleft.h = favorites_pgright.h;
27006 5 favorites_pgleft.x = favorites_pgright.x - favorites_pgleft.w;
27007 5 favorites_pgleft.y = favorites_pgright.y;
27008
27009 5 mainbar.x = dialogs[0].x+dialogs[0].w;
27010 5 mainbar.y = 0;
27011 5 mainbar.w = compactbtn.x-mainbar.x;
27012 5 mainbar.h = drawmode_btn.h;
27013 }
27014
27015 //Ensure current combo list selected is valid
27016 5 current_combolist=vbound(current_combolist,0,num_combo_cols-1);
27017 5 current_comboalist=vbound(current_comboalist,0,num_combo_cols-1);
27018 5 current_cpoollist=vbound(current_cpoollist,0,num_combo_cols-1);
27019 5 current_cautolist = vbound(current_cautolist, 0, num_combo_cols - 1);
27020
27021 //Generate bitmaps
27022 5 init_bitmap(&mapscreenbmp,16*(showedges?18:16),16*(showedges?13:11));
27023 5 init_bitmap(&brushbmp,256*mapscreensize,176*mapscreensize);
27024 5 init_bitmap(&brushscreen,(256+(showedges?16:0))*mapscreensize,(176+(showedges?16:0))*mapscreensize);
27025
27026 5 init_bitmap(&screen2,zq_screen_w,zq_screen_h);
27027 5 init_bitmap(&tmp_scr,zq_screen_w,zq_screen_h);
27028 5 init_bitmap(&menu1,zq_screen_w,zq_screen_h);
27029 5 init_bitmap(&menu3,zq_screen_w,zq_screen_h);
27030
27031 5 center_zq_class_dialogs();
27032 5 center_zq_custom_dialogs();
27033 5 center_zq_files_dialogs();
27034 5 center_zq_subscreen_dialogs();
27035 5 center_zq_tiles_dialogs();
27036 5 center_zquest_dialogs();
27037
27038 5 aspect_ratio = zq_screen_h / double(zq_screen_w);
27039
27040 5 mmap_init();
27041 5 }
27042
27043 void remove_locked_params_on_exit()
27044 {
27045 al_trace("Removing timers. \n");
27046 remove_int(fps_callback);
27047 remove_int(myvsync_callback);
27048 remove_int(dclick_check);
27049 }
27050
27051 void destroy_bitmaps_on_exit()
27052 {
27053 al_trace("Cleaning bitmaps...");
27054 destroy_bitmap(screen2);
27055 destroy_bitmap(tmp_scr);
27056 destroy_bitmap(menu1);
27057 destroy_bitmap(menu3);
27058 destroy_bitmap(mapscreenbmp);
27059 destroy_bitmap(dmapbmp_small);
27060 destroy_bitmap(dmapbmp_large);
27061 destroy_bitmap(brushbmp);
27062 destroy_bitmap(brushscreen);
27063 al_trace("...");
27064
27065 for(int32_t i=0; i<MOUSE_BMP_MAX*4; i++)
27066 {
27067 destroy_bitmap(mouse_bmp[i/4][i%4]);
27068 destroy_bitmap(mouse_bmp_1x[i/4][i%4]);
27069 }
27070
27071 for(int32_t i=0; i<ICON_BMP_MAX*4; i++)
27072 destroy_bitmap(icon_bmp[i/4][i%4]);
27073
27074 for(int32_t i=0; i<16*4; i++)
27075 destroy_bitmap(flag_bmp[i/4][i%4]);
27076 for(int32_t i=0; i<2; i++)
27077 destroy_bitmap(select_bmp[i]);
27078
27079 for(int32_t i=0; i<MAXARROWS; i++)
27080 destroy_bitmap(arrow_bmp[i]);
27081
27082 al_trace(" OK. \n");
27083 }
27084
27085
27086 void quit_game()
27087 {
27088 set_last_timed_save(nullptr);
27089 save_config_file();
27090 zc_set_palette(black_palette);
27091 zc_stop_midi();
27092
27093 remove_locked_params_on_exit();
27094
27095 al_trace("Cleaning sfx. \n");
27096
27097 for(int32_t i=0; i<WAV_COUNT; i++)
27098 {
27099 if(customsfxdata[i].data!=NULL)
27100 {
27101 // delete [] customsfxdata[i].data;
27102 free(customsfxdata[i].data);
27103 }
27104
27105 delete [] sfx_string[i];
27106 }
27107
27108 for(int32_t i=0; i<MAXWPNS; i++)
27109 {
27110 delete [] weapon_string[i];
27111 }
27112
27113 for(int32_t i=0; i<MAXITEMS; i++)
27114 {
27115 delete [] item_string[i];
27116 }
27117
27118 for(int32_t i=0; i<eMAXGUYS; i++)
27119 {
27120 delete [] guy_string[i];
27121 }
27122
27123 al_trace("Cleaning script buffer. \n");
27124
27125 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
27126 {
27127 if(ffscripts[i]!=NULL) delete ffscripts[i];
27128 }
27129
27130 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
27131 {
27132 if(itemscripts[i]!=NULL) delete itemscripts[i];
27133 }
27134
27135 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
27136 {
27137 if(guyscripts[i]!=NULL) delete guyscripts[i];
27138 }
27139
27140 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
27141 {
27142 if(lwpnscripts[i]!=NULL) delete lwpnscripts[i];
27143 }
27144
27145 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
27146 {
27147 if(ewpnscripts[i]!=NULL) delete ewpnscripts[i];
27148 }
27149
27150 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
27151 {
27152 if(screenscripts[i]!=NULL) delete screenscripts[i];
27153 }
27154
27155 for(int32_t i=0; i<3; i++) //should this be NUMSCRIPTGLOBAL or NUMSCRIPTGLOBALOLD? -Z
27156 {
27157 if(globalscripts[i]!=NULL) delete globalscripts[i];
27158 }
27159
27160 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
27161 {
27162 if(playerscripts[i]!=NULL) delete playerscripts[i];
27163 }
27164
27165 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
27166 {
27167 if(dmapscripts[i]!=NULL) delete dmapscripts[i];
27168 }
27169 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
27170 {
27171 if(itemspritescripts[i]!=NULL) delete itemspritescripts[i];
27172 }
27173 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
27174 {
27175 if(comboscripts[i]!=NULL) delete comboscripts[i];
27176 }
27177 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
27178 {
27179 if(subscreenscripts[i]!=NULL) delete subscreenscripts[i];
27180 }
27181
27182 al_trace("Cleaning qst buffers. \n");
27183 del_qst_buffers();
27184
27185
27186 al_trace("Cleaning midis. \n");
27187
27188 if(customtunes)
27189 {
27190 for(int32_t i=0; i<MAXCUSTOMMIDIS_ZQ; i++)
27191 customtunes[i].reset();
27192
27193 free(customtunes);
27194 }
27195
27196 al_trace("Cleaning undotilebuf. \n");
27197
27198 undocombobuf.clear();
27199
27200 if(newundotilebuf)
27201 {
27202 for(int32_t i=0; i<NEWMAXTILES; i++)
27203 if(newundotilebuf[i].data) free(newundotilebuf[i].data);
27204
27205 free(newundotilebuf);
27206 }
27207
27208 if(filepath) free(filepath);
27209
27210 if(temppath) free(temppath);
27211
27212 if(datapath) free(datapath);
27213
27214 if(midipath) free(midipath);
27215
27216 if(imagepath) free(imagepath);
27217
27218 if(tmusicpath) free(tmusicpath);
27219
27220 if(last_timed_save) free(last_timed_save);
27221
27222 destroy_bitmaps_on_exit();
27223 }
27224
27225 void quit_game2()
27226 {
27227 set_last_timed_save(nullptr);
27228 save_config_file();
27229 zc_set_palette(black_palette);
27230 zc_stop_midi();
27231
27232 remove_locked_params_on_exit();
27233
27234 al_trace("Cleaning sfx. \n");
27235
27236 for(int32_t i=0; i<WAV_COUNT; i++)
27237 {
27238 if(customsfxdata[i].data!=NULL)
27239 {
27240 // delete [] customsfxdata[i].data;
27241 free(customsfxdata[i].data);
27242 }
27243
27244 delete [] sfx_string[i];
27245 }
27246
27247 for(int32_t i=0; i<MAXWPNS; i++)
27248 {
27249 delete [] weapon_string[i];
27250 }
27251
27252 for(int32_t i=0; i<MAXITEMS; i++)
27253 {
27254 delete [] item_string[i];
27255 }
27256
27257 for(int32_t i=0; i<eMAXGUYS; i++)
27258 {
27259 delete [] guy_string[i];
27260 }
27261
27262 al_trace("Cleaning script buffer. \n");
27263
27264 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
27265 {
27266 if(ffscripts[i]!=NULL) delete ffscripts[i];
27267 }
27268
27269 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
27270 {
27271 if(itemscripts[i]!=NULL) delete itemscripts[i];
27272 }
27273
27274 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
27275 {
27276 if(guyscripts[i]!=NULL) delete guyscripts[i];
27277 }
27278
27279 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
27280 {
27281 if(lwpnscripts[i]!=NULL) delete lwpnscripts[i];
27282 }
27283
27284 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
27285 {
27286 if(ewpnscripts[i]!=NULL) delete ewpnscripts[i];
27287 }
27288
27289 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
27290 {
27291 if(screenscripts[i]!=NULL) delete screenscripts[i];
27292 }
27293
27294 for(int32_t i=0; i<3; i++) //should this be NUMSCRIPTGLOBAL or NUMSCRIPTGLOBALOLD? -Z
27295 {
27296 if(globalscripts[i]!=NULL) delete globalscripts[i];
27297 }
27298
27299 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
27300 {
27301 if(playerscripts[i]!=NULL) delete playerscripts[i];
27302 }
27303
27304 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
27305 {
27306 if(dmapscripts[i]!=NULL) delete dmapscripts[i];
27307 }
27308 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
27309 {
27310 if(itemspritescripts[i]!=NULL) delete itemspritescripts[i];
27311 }
27312 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
27313 {
27314 if(comboscripts[i]!=NULL) delete comboscripts[i];
27315 }
27316 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
27317 {
27318 if(subscreenscripts[i]!=NULL) delete subscreenscripts[i];
27319 }
27320
27321 al_trace("Cleaning qst buffers. \n");
27322 del_qst_buffers();
27323
27324
27325 al_trace("Cleaning midis. \n");
27326
27327 if(customtunes)
27328 {
27329 for(int32_t i=0; i<MAXCUSTOMMIDIS_ZQ; i++)
27330 customtunes[i].reset();
27331
27332 free(customtunes);
27333 }
27334
27335 al_trace("Cleaning undotilebuf. \n");
27336
27337 undocombobuf.clear();
27338
27339 if(newundotilebuf)
27340 {
27341 for(int32_t i=0; i<NEWMAXTILES; i++)
27342 if(newundotilebuf[i].data) free(newundotilebuf[i].data);
27343
27344 free(newundotilebuf);
27345 }
27346
27347 if(filepath) free(filepath);
27348
27349 if(temppath) free(temppath);
27350
27351 if(datapath) free(datapath);
27352
27353 if(midipath) free(midipath);
27354
27355 if(imagepath) free(imagepath);
27356
27357 if(tmusicpath) free(tmusicpath);
27358
27359 if(last_timed_save) free(last_timed_save);
27360 }
27361
27362 5 void center_zquest_dialogs()
27363 {
27364 5 jwin_center_dialog(assignscript_dlg);
27365 5 jwin_center_dialog(autolayer_dlg);
27366 5 jwin_center_dialog(cpage_dlg);
27367 5 center_zq_cset_dialogs();
27368 5 jwin_center_dialog(change_track_dlg);
27369 5 jwin_center_dialog(csetfix_dlg);
27370 5 jwin_center_dialog(dmapmaps_dlg);
27371 5 center_zq_door_dialogs();
27372 5 jwin_center_dialog(editcomboa_dlg);
27373 5 jwin_center_dialog(editinfo_dlg);
27374 5 jwin_center_dialog(editmidi_dlg);
27375 5 jwin_center_dialog(editmusic_dlg);
27376 5 jwin_center_dialog(editshop_dlg);
27377 5 jwin_center_dialog(elist_dlg);
27378 5 jwin_center_dialog(enemy_dlg);
27379 5 jwin_center_dialog(ffcombo_sel_dlg);
27380 5 jwin_center_dialog(getnum_dlg);
27381 5 jwin_center_dialog(glist_dlg);
27382 5 jwin_center_dialog(layerdata_dlg);
27383 5 jwin_center_dialog(list_dlg);
27384 5 jwin_center_dialog(loadmap_dlg);
27385 5 jwin_center_dialog(mapstyles_dlg);
27386 5 jwin_center_dialog(misccolors_dlg);
27387 5 jwin_center_dialog(newcomboa_dlg);
27388 5 jwin_center_dialog(orgcomboa_dlg);
27389 5 jwin_center_dialog(path_dlg);
27390 5 jwin_center_dialog(pattern_dlg);
27391 5 jwin_center_dialog(screen_pal_dlg);
27392 5 jwin_center_dialog(secret_dlg);
27393 5 jwin_center_dialog(selectdmap_dlg);
27394 5 jwin_center_dialog(selectmidi_dlg);
27395 5 jwin_center_dialog(selectmusic_dlg);
27396 5 jwin_center_dialog(sfxlist_dlg);
27397 5 jwin_center_dialog(sfx_edit_dlg);
27398 5 jwin_center_dialog(showpal_dlg);
27399 5 jwin_center_dialog(strlist_dlg);
27400 5 jwin_center_dialog(template_dlg);
27401 5 jwin_center_dialog(tp_dlg);
27402 5 jwin_center_dialog(under_dlg);
27403 5 jwin_center_dialog(tilewarp_dlg);
27404 5 jwin_center_dialog(sidewarp_dlg);
27405 5 jwin_center_dialog(warpring_dlg);
27406 5 jwin_center_dialog(wlist_dlg);
27407 5 center_zscript_dialogs();
27408 5 }
27409
27410
27411 void animate_coords()
27412 {
27413 coord_frame=(coord_timer>>3)&3;
27414
27415 if(++coord_timer>=(1<<5))
27416 {
27417 coord_timer=0;
27418 }
27419 }
27420
27421 static const char *help_list[] =
27422 {
27423 "PREVIEW MODE",
27424 "PgUp/PgDn - Scroll through hotkey list",
27425 "Esc/Enter - Exit Preview Mode",
27426 "R - Restore screen to original state",
27427 "C - Toggle combo cycling On/Off",
27428 "S - Trigger screen secrets",
27429 "Q/W/F - These still work",
27430 "P - Pause everything",
27431 "A - Advance frame-by-frame",
27432 "1-4 - Trigger tile warp A-D",
27433 "5-8 - Trigger side warp A-D",
27434 "9 - Enable timed warps",
27435 "",
27436 "",
27437 };
27438
27439 void do_previewtext()
27440 {
27441 FONT* oldfont = font;
27442 font = get_zc_font(font_lfont_l);
27443
27444 //Put in help areas
27445 auto& sqr = preview_text;
27446 int ind = 0, len = 0;
27447 for(int q = 0; q < 12; ++q)
27448 {
27449 int l = text_length(font, help_list[q]);
27450 if(len < l) len = l;
27451 }
27452 sqr.xscale = len+2;
27453 sqr.yscale = text_height(font);
27454 for(int col = 0; col < sqr.w; ++col)
27455 {
27456 for(int row = 0; row < sqr.h; ++row)
27457 {
27458 auto& line = sqr.subsquare(col,row);
27459 textprintf_ex(menu1,font,line.x,line.y,jwin_pal[jcTEXTFG],-1,"%s",help_list[ind++]);
27460 }
27461 }
27462
27463 font = oldfont;
27464 }
27465
27466
27467 bool reload_fonts = false;
27468 void run_zq_frame()
27469 {
27470 if(reload_fonts)
27471 {
27472 init_custom_fonts();
27473 load_size_poses();
27474 reload_fonts = false;
27475 }
27476
27477 domouse();
27478 custom_vsync();
27479 refresh(rCLEAR|rALL);
27480 }
27481 5 int32_t d_nbmenu_proc(int32_t msg,DIALOG *d,int32_t c)
27482 {
27483
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
5 switch(msg)
27484 {
27485 case MSG_VSYNC:
27486 run_zq_frame();
27487 break;
27488 case MSG_GOTMOUSE:
27489 case MSG_XCHAR:
27490 ComboBrushPause=1;
27491 refresh(rMAP);
27492 ComboBrushPause=0;
27493 clear_tooltip();
27494 break;
27495 }
27496
27497 5 return GuiMenu::proc(msg,d,c);
27498 }
27499
27500 bool prv_press=false;
27501
27502 void dopreview()
27503 {
27504 refresh(rMAP);
27505
27506 while(!(gui_mouse_b()))
27507 {
27508 if(keypressed())
27509 {
27510 if(!prv_press)
27511 {
27512 prv_press=true;
27513
27514 switch(readkey()>>8)
27515 {
27516 case KEY_ESC:
27517 case KEY_ENTER:
27518 case KEY_ENTER_PAD:
27519 goto finished;
27520 break;
27521
27522 case KEY_F:
27523 Flags^=cFLAGS;
27524 refresh(rMAP);
27525 break;
27526
27527 case KEY_R:
27528 onReloadPreview();
27529 break;
27530
27531 case KEY_S:
27532 onSecretsPreview();
27533 break;
27534
27535 case KEY_C:
27536 onCopy();
27537 break;
27538
27539 case KEY_A:
27540 onAKey();
27541 break;
27542
27543 case KEY_P:
27544 onP();
27545 break;
27546
27547 case KEY_L:
27548 onShowDarkness();
27549 break;
27550
27551 case KEY_1:
27552 Map.prv_dowarp(0,0);
27553 prv_warp=0;
27554 break;
27555
27556 case KEY_2:
27557 Map.prv_dowarp(0,1);
27558 prv_warp=0;
27559 break;
27560
27561 case KEY_3:
27562 Map.prv_dowarp(0,2);
27563 prv_warp=0;
27564 break;
27565
27566 case KEY_4:
27567 Map.prv_dowarp(0,3);
27568 prv_warp=0;
27569 break;
27570
27571 case KEY_5:
27572 Map.prv_dowarp(1,0);
27573 prv_warp=0;
27574 break;
27575
27576 case KEY_6:
27577 Map.prv_dowarp(1,1);
27578 prv_warp=0;
27579 break;
27580
27581 case KEY_7:
27582 Map.prv_dowarp(1,2);
27583 prv_warp=0;
27584 break;
27585
27586 case KEY_8:
27587 Map.prv_dowarp(1,3);
27588 prv_warp=0;
27589 break;
27590
27591 case KEY_9:
27592 if(prv_twon)
27593 {
27594 prv_twon=0;
27595 Map.set_prvtime(0);
27596 prv_warp=0;
27597 }
27598 else
27599 {
27600 Map.set_prvtime(Map.get_prvscr()->timedwarptics);
27601 prv_twon=1;
27602 }
27603
27604 break;
27605
27606 case KEY_W:
27607 onShowWalkability();
27608 break;
27609
27610 case KEY_Q:
27611 onShowComboInfoCSet();
27612 break;
27613 }
27614 }
27615 else
27616 {
27617 readkey();
27618 }
27619 }
27620 else
27621 {
27622 prv_press=false;
27623 }
27624
27625 if(prv_warp)
27626 {
27627 Map.prv_dowarp(1,0);
27628 prv_warp=0;
27629 }
27630
27631 if(Map.get_prvfreeze())
27632 {
27633 if(Map.get_prvadvance())
27634 {
27635 custom_vsync();
27636 Map.set_prvadvance(0);
27637 }
27638 }
27639 else
27640 {
27641 custom_vsync();
27642 Map.set_prvadvance(0);
27643 }
27644
27645 refresh(rALL);
27646 }
27647
27648 finished:
27649 //Flags=of;
27650 reset_combo_animations();
27651 reset_combo_animations2();
27652 MouseSprite::set(ZQM_NORMAL);
27653 prv_mode=0;
27654 Map.set_prvcmb(0);
27655 Map.set_prvadvance(0);
27656 Map.set_prvfreeze(0);
27657 Map.set_prvtime(0);
27658 prv_warp=0;
27659 loadlvlpal(Map.getcolor());
27660 rebuild_trans_table();
27661 refresh(rMAP+rMENU);
27662
27663 while(gui_mouse_b())
27664 {
27665 /* do nothing */
27666 rest(1);
27667 }
27668 }
27669
27670 void call_vidmode_dlg();
27671 int32_t onZQVidMode()
27672 {
27673 call_vidmode_dlg();
27674 return D_O_K;
27675 }
27676
27677 9 bool is_editor()
27678 {
27679 9 return true;
27680 }
27681
27682 bool screenIsScrolling()
27683 {
27684 return false;
27685 }
27686
27687 void write_includepaths()
27688 {
27689 FILE* f = fopen("includepaths.txt", "w");
27690 if(f)
27691 {
27692 fwrite(FFCore.includePathString,1,strlen(FFCore.includePathString),f);
27693 fclose(f);
27694 }
27695 }
27696
27697 int32_t save_config_file()
27698 {
27699 char qtnametitle[20];
27700 char qtpathtitle[20];
27701 char *datapath2=(char *)malloc(2048);
27702 char *midipath2=(char *)malloc(2048);
27703 char *imagepath2=(char *)malloc(2048);
27704 char *tmusicpath2=(char *)malloc(2048);
27705 strcpy(datapath2, datapath);
27706 strcpy(midipath2, midipath);
27707 strcpy(imagepath2, imagepath);
27708 strcpy(tmusicpath2, tmusicpath);
27709 chop_path(datapath2);
27710 chop_path(midipath2);
27711 chop_path(imagepath2);
27712 chop_path(tmusicpath2);
27713
27714 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
27715 //
27716 write_includepaths();
27717
27718 zc_set_config("zquest",data_path_name,datapath2);
27719 zc_set_config("zquest",midi_path_name,midipath2);
27720 zc_set_config("zquest",image_path_name,imagepath2);
27721 zc_set_config("zquest",tmusic_path_name,tmusicpath2);
27722
27723 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
27724 {
27725 window_width = al_get_display_width(all_get_display());
27726 window_height = al_get_display_height(all_get_display());
27727 zc_set_config("zquest","window_width",window_width);
27728 zc_set_config("zquest","window_height",window_height);
27729 }
27730 if (all_get_display() && !all_get_fullscreen_flag() && SaveWinPos)
27731 {
27732 int o_window_x, o_window_y;
27733 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
27734 zc_set_config("zquest", "window_x", o_window_x);
27735 zc_set_config("zquest", "window_y", o_window_y);
27736 }
27737
27738 byte b = 0;
27739 for(int32_t x=0; x<7; x++)
27740 {
27741 set_bit(&b,x,LayerMaskInt[x]);
27742 }
27743
27744 zc_set_config("zquest","layer_mask",b);
27745
27746 flush_config_file();
27747 #ifdef __EMSCRIPTEN__
27748 em_sync_fs();
27749 #endif
27750 free(datapath2);
27751 free(midipath2);
27752 free(imagepath2);
27753 free(tmusicpath2);
27754 return 0;
27755 }
27756
27757 int32_t d_timer_proc(int32_t msg, DIALOG *d, int32_t c)
27758 {
27759 //these are here to bypass compiler warnings about unused arguments
27760 c=c;
27761 d=d;
27762
27763 switch(msg)
27764 {
27765 case MSG_IDLE:
27766 #ifdef _WIN32
27767 if(zqUseWin32Proc != FALSE)
27768 win32data.Update(Frameskip); //experimental win32 fixes
27769
27770 #endif
27771
27772 // This has been crashing on Windows, and it saves plenty without it
27773 //check_autosave();
27774 break;
27775 }
27776
27777 return D_O_K;
27778 }
27779
27780 void check_autosave()
27781 {
27782 if (!first_save)
27783 return;
27784
27785 if(AutoSaveInterval>0)
27786 {
27787 time(&auto_save_time_current);
27788 auto_save_time_diff = difftime(auto_save_time_current,auto_save_time_start);
27789
27790 if(auto_save_time_diff>AutoSaveInterval*60)
27791 {
27792 MouseSprite::set(ZQM_NORMAL);
27793 replace_extension(last_timed_save, filepath, "qt0", 2047);
27794 set_last_timed_save(last_timed_save);
27795 go();
27796
27797 if((header.zelda_version != ZELDA_VERSION || header.build != VERSION_BUILD))
27798 {
27799 jwin_alert("Auto Save","This quest was saved in an older version of ZQuest.","If you wish to use the autosave feature, you must manually","save the files in this version first.","OK",NULL,13,27,get_zc_font(font_lfont));
27800 time(&auto_save_time_start);
27801 comeback();
27802 return;
27803 }
27804
27805 int32_t ret = save_quest(last_timed_save, true);
27806
27807 if(ret)
27808 {
27809 jwin_alert("Error","Timed save did not complete successfully.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
27810 set_last_timed_save(nullptr);
27811 }
27812
27813 save_config_file();
27814 time(&auto_save_time_start);
27815 comeback();
27816 }
27817 }
27818 }
27819
27820 void flushItemCache(bool) {}
27821 void ringcolor(bool forceDefault)
27822 {
27823 forceDefault=forceDefault;
27824 }
27825
27826 bool item_disabled(int32_t)
27827 {
27828 return false;
27829 }
27830
27831 int32_t onCmdExit()
27832 {
27833 // replaces onExit for the -large button command "Exit"
27834 close_button_quit = true;
27835 return 0;
27836 }
27837
27838 int32_t onQuickCompile()
27839 {
27840 if(do_compile_and_slots(1,false))
27841 {
27842 saved = false;
27843 InfoDialog("Quick Compile","Success!").show();
27844 }
27845 else
27846 {
27847 InfoDialog("Quick Compile","Failure!").show();
27848 }
27849 return 0;
27850 }
27851 int32_t onSmartCompile()
27852 {
27853 if(do_compile_and_slots(2,false))
27854 {
27855 saved = false;
27856 InfoDialog("Smart Compile","Success!").show();
27857 }
27858 else
27859 {
27860 InfoDialog("Smart Compile","Failure!").show();
27861 }
27862 return 0;
27863 }
27864
27865 /********************************/
27866 /***** Tool Tips ******/
27867 /********************************/
27868 int32_t strchrnum(char const* str, char c)
27869 {
27870 for(int32_t i=0; str[i]; ++i)
27871 {
27872 if(str[i]==c)
27873 {
27874 return i;
27875 }
27876 }
27877
27878 return -1;
27879 }
27880
27881 int32_t get_longest_line_length(FONT *f, char* str)
27882 {
27883 int32_t maxlen=0;
27884 char* tmpstr = str;
27885 char temp=0;
27886 int32_t t=0;
27887 int32_t new_t=-1;
27888 while(tmpstr[0])
27889 {
27890 t=strchrnum(tmpstr, '\n');
27891
27892 if(t==-1)
27893 {
27894 t=(int32_t)strlen(tmpstr);
27895 }
27896
27897 if((uint32_t)t!=strlen(tmpstr))
27898 {
27899 new_t=t+1;
27900 }
27901 else
27902 {
27903 new_t=-1;
27904 }
27905
27906 temp = tmpstr[t];
27907 tmpstr[t]=0;
27908 maxlen=zc_max(maxlen,text_length(f, tmpstr));
27909 tmpstr[t]=temp;
27910
27911 if(new_t!=-1)
27912 {
27913 tmpstr+=new_t;
27914 }
27915 else break;
27916 }
27917 return maxlen;
27918 }
27919
27920 int32_t count_lines(char const* str)
27921 {
27922 int32_t count=1;
27923
27924 for(word i=0; i<strlen(str); ++i)
27925 {
27926 if(str[i]=='\n')
27927 {
27928 ++count;
27929 }
27930 }
27931
27932 return count;
27933 }
27934
27935 void debug_pos(size_and_pos const& pos, int color)
27936 {
27937 if(pos.w < 1 || pos.h < 1)
27938 return;
27939 if(pos.xscale > 1 || pos.yscale > 1)
27940 {
27941 auto maxind = pos.w*pos.h;
27942 for(auto q = 0; q < maxind; ++q)
27943 {
27944 auto& sub = pos.subsquare(q);
27945 if(sub.x < 0) break;
27946 highlight_sqr(screen, color, sub, 1);
27947 }
27948 }
27949 else
27950 {
27951 if(pos.fw > -1 && pos.fh > -1)
27952 highlight_frag(screen, color, pos, 1);
27953 else highlight_sqr(screen, color, pos, 1);
27954 }
27955 }
27956
27957 void textbox_out(BITMAP* dest, FONT* font, int x, int y, int fg, int bg, char const* str, int align, size_and_pos* dims)
27958 {
27959 static size_and_pos nilsz;
27960 size_and_pos& txbox = dims ? *dims : nilsz;
27961
27962 char* kill = (char*)malloc(strlen(str)+1);
27963 char *tmpstr = kill;
27964 strcpy(tmpstr,str);
27965
27966 while(tmpstr[0] == '\n')
27967 ++tmpstr;
27968 int len = strlen(tmpstr);
27969 while(tmpstr[len-1] == '\n')
27970 tmpstr[--len] = 0;
27971
27972 txbox.x=x;
27973 txbox.y=y;
27974 int32_t lines=count_lines(tmpstr);
27975 txbox.w = 1;
27976 txbox.h = lines;
27977 txbox.xscale = get_longest_line_length(font, tmpstr);
27978 txbox.yscale = text_height(font);
27979
27980 int ax = 0; //Aligned x
27981 switch(align)
27982 {
27983 case 0: //left
27984 break;
27985 case 1: //center
27986 txbox.x -= txbox.xscale/2;
27987 ax = txbox.xscale/2;
27988 break;
27989 case 2: //right
27990 txbox.x -= txbox.xscale;
27991 ax = txbox.xscale;
27992 break;
27993 }
27994
27995 int bw = txbox.w*txbox.xscale;
27996 int bh = txbox.h*txbox.yscale;
27997 BITMAP* outbmp = create_bitmap_ex(8, bw, bh);
27998 clear_to_color(outbmp, bg);
27999
28000 char temp = 0;
28001 int32_t t=0;
28002 int32_t new_t=-1;
28003 int32_t line=0;
28004
28005 while(tmpstr[t])
28006 {
28007 t=strchrnum(tmpstr, '\n');
28008
28009 if(t==-1)
28010 t=(int32_t)strlen(tmpstr);
28011
28012 if((uint32_t)t!=strlen(tmpstr))
28013 new_t=t+1;
28014 else
28015 new_t=-1;
28016
28017 temp = tmpstr[t];
28018 tmpstr[t]=0;
28019 gui_textout_ln(outbmp, font, (ucc*)tmpstr, ax, (line*txbox.yscale), fg, -1, align);
28020 tmpstr[t]=temp;
28021 ++line;
28022
28023 if(new_t!=-1)
28024 {
28025 tmpstr+=new_t;
28026 t=0;
28027 }
28028 }
28029
28030 blit(outbmp, dest, 0, 0, txbox.x, txbox.y, bw, bh);
28031 destroy_bitmap(outbmp);
28032 free(kill);
28033 }
28034
28035 void highlight_sqr(BITMAP* dest, int color, int x, int y, int w, int h, int thick)
28036 {
28037 for(int q = 0; q < thick; ++q)
28038 {
28039 safe_rect(dest, x+q, y+q, x+w-1-q, y+h-1-q, color);
28040 }
28041 }
28042 void highlight_sqr(BITMAP* dest, int color, size_and_pos const& rec, int thick)
28043 {
28044 highlight_sqr(dest, color, rec.x, rec.y, rec.tw(), rec.th(), thick);
28045 }
28046 void highlight_frag(BITMAP* dest, int color, int x1, int y1, int w, int h, int fw, int fh, int thick)
28047 {
28048 int xc = x1+fw-1;
28049 int yc = y1+fh-1;
28050 int x2 = x1+w-1;
28051 int y2 = y1+h-1;
28052
28053 _allegro_hline(dest, x1, y1, x2, color);
28054 _allegro_vline(dest, x1, y1, y2, color);
28055
28056 _allegro_hline(dest, x1, y2, xc, color);
28057 _allegro_vline(dest, x2, y1, yc, color);
28058 _allegro_hline(dest, xc, yc, x2, color);
28059 _allegro_vline(dest, xc, yc, y2, color);
28060 }
28061 void highlight_frag(BITMAP* dest, int color, size_and_pos const& rec, int thick)
28062 {
28063 highlight_frag(dest, color, rec.x, rec.y, rec.tw(), rec.th(), rec.fw, rec.fh, thick);
28064 }
28065
28066 void highlight(BITMAP* dest, size_and_pos& hl)
28067 {
28068 if(hl.fw > -1 && hl.fh > -1)
28069 {
28070 highlight_frag(dest, hl.data[1], hl, hl.data[0]);
28071 }
28072 else highlight_sqr(dest, hl.data[1], hl, hl.data[0]);
28073 }
28074
28075 std::pair<int, int> get_box_text_size(char const* tipmsg, double txscale)
28076 {
28077 if(txscale < 1) txscale = 1;
28078 char* kill = (char*)malloc(strlen(tipmsg)+1);
28079 char *tmpstr = kill;
28080 strcpy(tmpstr,tipmsg);
28081
28082 while(tmpstr[0] == '\n')
28083 ++tmpstr;
28084 int len = strlen(tmpstr);
28085 while(tmpstr[len-1] == '\n')
28086 tmpstr[--len] = 0;
28087
28088 int32_t lines = count_lines(tmpstr);
28089 int txlen = get_longest_line_length(font, tmpstr);
28090 int txhei = lines*text_height(font);
28091 int tx_sclen = (txlen * txscale);
28092 int tx_schei = (txhei * txscale);
28093 int w = tx_sclen + 8 + 1;
28094 int h = tx_schei + 8 + 1;
28095 if (w > zq_screen_w)
28096 w = zq_screen_w;
28097 if (h > zq_screen_h)
28098 h = zq_screen_h;
28099 return {w, h};
28100 }
28101
28102 void draw_box(BITMAP* destbmp, size_and_pos* pos, char const* tipmsg, double txscale)
28103 {
28104 if(txscale < 1) txscale = 1;
28105 char* kill = (char*)malloc(strlen(tipmsg)+1);
28106 char *tmpstr = kill;
28107 strcpy(tmpstr,tipmsg);
28108
28109 while(tmpstr[0] == '\n')
28110 ++tmpstr;
28111 int len = strlen(tmpstr);
28112 while(tmpstr[len-1] == '\n')
28113 tmpstr[--len] = 0;
28114
28115 auto& box = *pos;
28116 clear_bitmap(destbmp);
28117
28118 int32_t lines=count_lines(tmpstr);
28119 int txlen = get_longest_line_length(font, tmpstr);
28120 int txhei = lines*text_height(font);
28121 int tx_sclen = (txlen * txscale);
28122 int tx_schei = (txhei * txscale);
28123 box.w = tx_sclen + 8 + 1;
28124 box.h = tx_schei + 8 + 1;
28125 if (box.w > zq_screen_w)
28126 box.w = zq_screen_w;
28127 if (box.h > zq_screen_h)
28128 box.h = zq_screen_h;
28129
28130 if(box.x+box.w>=zq_screen_w)
28131 {
28132 box.x=(zq_screen_w - box.w);
28133 }
28134
28135 if(box.y+box.h>=zq_screen_h)
28136 {
28137 box.y=(zq_screen_h - box.h);
28138 }
28139
28140 rectfill(destbmp, 1, 1, box.w-3, box.h-3, jwin_pal[jcTEXTBG]);
28141 rect(destbmp, 0, 0, box.w-2, box.h-2, jwin_pal[jcTEXTFG]);
28142 vline(destbmp, box.w-1, 0, box.h-1, jwin_pal[jcTEXTFG]);
28143 hline(destbmp, 1, box.h-1, box.w-2, jwin_pal[jcTEXTFG]);
28144 destbmp->line[box.h-1][0]=0;
28145 destbmp->line[0][box.w-1]=0;
28146
28147 char temp = 0;
28148 int32_t t=0;
28149 int32_t new_t=-1;
28150 int32_t line=0;
28151
28152 BITMAP* txbmp = create_bitmap_ex(8,box.w,box.h);
28153 clear_bitmap(txbmp);
28154 while(tmpstr[t])
28155 {
28156 t=strchrnum(tmpstr, '\n');
28157
28158 if(t==-1)
28159 {
28160 t=(int32_t)strlen(tmpstr);
28161 }
28162
28163 if((uint32_t)t!=strlen(tmpstr))
28164 {
28165 new_t=t+1;
28166 }
28167 else
28168 {
28169 new_t=-1;
28170 }
28171
28172 temp = tmpstr[t];
28173 tmpstr[t]=0;
28174 textprintf_ex(txbmp, font, 0, (line*text_height(font)), jwin_pal[jcTEXTFG], -1, "%s", tmpstr);
28175 tmpstr[t]=temp;
28176 ++line;
28177
28178 if(new_t!=-1)
28179 {
28180 tmpstr+=new_t;
28181 t=0;
28182 }
28183 }
28184 masked_stretch_blit(txbmp,destbmp,0,0,txlen,txhei,4,4,tx_sclen,tx_schei);
28185 destroy_bitmap(txbmp);
28186 free(kill);
28187 }
28188
28189 void update_tooltip(int32_t x, int32_t y, size_and_pos const& sqr, char const* tipmsg, double scale)
28190 {
28191 update_tooltip(x,y,sqr.x,sqr.y,sqr.w*sqr.xscale,sqr.h*sqr.yscale,tipmsg,sqr.fw,sqr.fh,scale);
28192 }
28193 void update_tooltip(int32_t x, int32_t y, int32_t tx, int32_t ty, int32_t tw, int32_t th, char const* tipmsg, int fw, int fh, double scale)
28194 {
28195 if(!EnableTooltips)
28196 {
28197 return;
28198 }
28199
28200 ttip_install(ttip_global_id, tipmsg, tx, ty, tw, th, x, y, fw, fh);
28201 }
28202
28203 void ZQ_ClearQuestPath()
28204 {
28205 zc_set_config("zquest","win_last_quest",(char const*)nullptr);
28206 strcpy(filepath,"");
28207 }
28208
28209 //FFCore
28210
28211 int32_t FFScript::GetScriptObjectUID(int32_t type)
28212 {
28213 ++script_UIDs[type];
28214 return script_UIDs[type];
28215 }
28216
28217 void FFScript::init()
28218 {
28219 for ( int32_t q = 0; q < wexLast; q++ ) warpex[q] = 0;
28220 numscriptdraws = 0;
28221 max_ff_rules = qr_MAX;
28222 temp_no_stepforward = 0;
28223 nostepforward = 0;
28224
28225 coreflags = 0;
28226 skip_ending_credits = 0;
28227 music_update_cond = 0;
28228 music_update_flags = 0;
28229 for ( int32_t q = 0; q < susptLAST; q++ ) { system_suspend[q] = 0; }
28230
28231 for ( int32_t q = 0; q < UID_TYPES; ++q ) { script_UIDs[q] = 0; }
28232 //for ( int32_t q = 0; q < 512; q++ ) FF_rules[q] = 0;
28233 int32_t usr_midi_volume = usr_digi_volume = usr_sfx_volume = usr_music_volume = usr_panstyle = 0;
28234 FF_hero_action = 0;
28235 enemy_removal_point[spriteremovalY1] = -32767;
28236 enemy_removal_point[spriteremovalY2] = 32767;
28237 enemy_removal_point[spriteremovalX1] = -32767;
28238 enemy_removal_point[spriteremovalX2] = 32767;
28239 enemy_removal_point[spriteremovalZ1] = -32767;
28240 enemy_removal_point[spriteremovalZ2] = 32767;
28241
28242 //Clear internal arrays for use by <std>, <ghost>, <tango>
28243 for ( int32_t q = 0; q < 256; ++q )
28244 {
28245 StdArray[q] = 0;
28246 GhostArray[q] = 0;
28247 TangoArray[q] = 0;
28248 }
28249
28250 for ( int32_t q = 0; q < 4; q++ )
28251 {
28252 FF_screenbounds[q] = 0;
28253 FF_screen_dimensions[q] = 0;
28254 FF_subscreen_dimensions[q] = 0;
28255 FF_eweapon_removal_bounds[q] = 0;
28256 FF_lweapon_removal_bounds[q] = 0;
28257 }
28258 for ( int32_t q = 0; q < FFSCRIPTCLASS_CLOCKS; q++ )
28259 {
28260 FF_clocks[q] = 0;
28261 }
28262 for ( int32_t q = 0; q < SCRIPT_DRAWING_RULES; q++ )
28263 {
28264 ScriptDrawingRules[q] = 0;
28265 }
28266 for ( int32_t q = 0; q < NUM_USER_MIDI_OVERRIDES; q++ )
28267 {
28268 FF_UserMidis[q] = 0;
28269 }
28270 subscreen_scroll_speed = 0; //make a define for a default and read quest override! -Z
28271 kb_typing_mode = false;
28272 initIncludePaths();
28273 initRunString();
28274 for(int32_t q = 0; q < 7; ++q)
28275 {
28276 tempScreens[q] = NULL;
28277 ScrollingScreens[q] = NULL;
28278 }
28279 }
28280
28281 void FFScript::updateIncludePaths()
28282 {
28283 includePaths.clear();
28284 int32_t pos = 0; int32_t pathnumber = 0;
28285 for ( int32_t q = 0; includePathString[pos]; ++q )
28286 {
28287 int32_t dest = 0;
28288 char buf[2048] = {0};
28289 while(includePathString[pos] != ';' && includePathString[pos])
28290 {
28291 buf[dest] = includePathString[pos];
28292 ++pos;
28293 ++dest;
28294 }
28295 ++pos;
28296 string str(buf);
28297 includePaths.push_back(str);
28298 }
28299 }
28300
28301 void FFScript::initRunString()
28302 {
28303 memset(scriptRunString,0,sizeof(scriptRunString));
28304 strcpy(scriptRunString,zc_get_config("Compiler","run_string","run",App::zscript));
28305 }
28306
28307 void FFScript::initIncludePaths()
28308 {
28309 memset(includePathString,0,sizeof(includePathString));
28310 FILE* f = fopen("includepaths.txt", "r");
28311 if(f)
28312 {
28313 int32_t pos = 0;
28314 int32_t c;
28315 do
28316 {
28317 c = fgetc(f);
28318 if(c!=EOF)
28319 includePathString[pos++] = c;
28320 }
28321 while(c!=EOF && pos<MAX_INCLUDE_PATH_CHARS);
28322 if(pos<MAX_INCLUDE_PATH_CHARS)
28323 includePathString[pos] = '\0';
28324 includePathString[MAX_INCLUDE_PATH_CHARS-1] = '\0';
28325 fclose(f);
28326 }
28327 else strcpy(includePathString, "include/;headers/;scripts/;");
28328 al_trace("Full path string is: ");
28329 safe_al_trace(includePathString);
28330 al_trace("\n");
28331 updateIncludePaths();
28332
28333 for ( size_t q = 0; q < includePaths.size(); ++q )
28334 {
28335 al_trace("Include path %zu: ",q);
28336 safe_al_trace(includePaths.at(q).c_str());
28337 al_trace("\n");
28338 }
28339 }
28340
28341 int32_t FFScript::getQRBit(int32_t rule)
28342 {
28343 return ( get_qr(rule) ? 1 : 0 );
28344 }
28345
28346 int32_t FFScript::getTime(int32_t type)
28347 {
28348 //struct tm *tm_struct = localtime(time(NULL));
28349 struct tm * tm_struct;
28350 time_t rawtime;
28351 time (&rawtime);
28352 tm_struct = localtime (&rawtime);
28353
28354 switch(type)
28355 {
28356 case curyear:
28357 {
28358 int32_t year = tm_struct->tm_year + 1900; /* year */
28359 //year format starts at 1900, so we add it to the return
28360 //al_trace("The current year is: %d\n",year);
28361 return year;
28362
28363 }
28364 case curmonth:
28365 {
28366 int32_t month = tm_struct->tm_mon +1; /* month */
28367 //Months start at 0, but we want 1->12
28368 //al_trace("The current month is: %d\n",month);
28369 return month;
28370 }
28371 case curday_month:
28372 {
28373 int32_t day_month = tm_struct->tm_mday; /* day of the month */
28374 //al_trace("The current day of the month is: %d\n",day_month);
28375 return day_month;
28376 }
28377 case curday_week:
28378 {
28379 int32_t day_week = tm_struct->tm_wday; /* day of the week */
28380 //al_trace("The current day of the week is: %d\n",day_week);
28381 return day_week;
28382 }
28383 case curhour:
28384 {
28385 int32_t hour = tm_struct->tm_hour; /* hours */
28386 //al_trace("The current hour is: %d\n",hour);
28387 return hour;
28388 }
28389 case curminute:
28390 {
28391 int32_t minutes = tm_struct->tm_min; /* minutes */
28392 //al_trace("The current hour is: %d\n",minutes);
28393 return minutes;
28394 }
28395 case cursecond:
28396 {
28397 int32_t secs = tm_struct->tm_sec; /* seconds */
28398 //al_trace("The current second is: %d\n",secs);
28399 return secs;
28400 }
28401 case curdayyear:
28402 {
28403 int32_t day_year = tm_struct->tm_yday; /* day in the year */
28404 //al_trace("The current day out of the year is: %d\n",day_year);
28405 return day_year;
28406 }
28407 case curDST:
28408 {
28409 int32_t isDST = tm_struct->tm_isdst; /* daylight saving time */
28410 //al_trace("The current DSTis: %d\n",isDST);
28411 return isDST;
28412 }
28413 default: return -1;
28414
28415 }
28416 }
28417
28418 extern const char *itemclass_help_string_defaults[itype_max];
28419 //ZModule Functions
28420
28421
28422
28423 /* end */
28424
28425 13312 int32_t FFScript::getQuestHeaderInfo(int32_t type)
28426 {
28427 13312 return quest_format[type];
28428 }
28429
28430 bool isSideViewGravity(int32_t t)
28431 {
28432 return (Map.CurrScr()->flags7&fSIDEVIEW) != 0;
28433 }
28434
28435
28436
28437
28438 void FFScript::ZScriptConsole(bool open)
28439 {
28440
28441
28442 #ifdef _WIN32
28443 if ( console_is_open )
28444 {
28445 zscript_coloured_console.Create("ZQuest Classic Logging Console", 600, 200);
28446 zscript_coloured_console.cls(CConsoleLoggerEx::COLOR_BACKGROUND_BLACK);
28447 zscript_coloured_console.gotoxy(0,0);
28448 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
28449 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"ZQuest Classic Logging Console\n");
28450 }
28451 else
28452 {
28453 //close
28454 zscript_coloured_console.Close();
28455 }
28456 #endif
28457 }
28458
28459 template <typename ...Params>
28460 void FFScript::ZScriptConsole(int32_t attributes,const char *format, Params&&... params)
28461 {
28462 #ifdef _WIN32
28463 initConsole();
28464 zscript_coloured_console.cprintf( attributes, format, std::forward<Params>(params)... );
28465 #endif
28466 }
28467
28468 int32_t getpitfall(int32_t x, int32_t y){return 0;}
28469
28470 int32_t iswaterexzq(int32_t combo, int32_t map, int32_t screen, int32_t layer, int32_t x, int32_t y, bool secrets, bool fullcheck, bool LayerCheck){return 0;}
28471
28472 int32_t MAPCOMBOzq(int32_t x, int32_t y){return 0;}
28473
28474 bool update_hw_pal = false;
28475 void update_hw_screen(bool force)
28476 {
28477 if (is_headless())
28478 return;
28479
28480 if(force || myvsync)
28481 {
28482 zc_process_display_events();
28483 if(update_hw_pal)
28484 {
28485 zc_set_palette(RAMpal);
28486 update_hw_pal=false;
28487 }
28488 if (force || myvsync)
28489 render_zq();
28490 myvsync=0;
28491 ++framecnt;
28492 }
28493 }
28494
28495 bool checkCost(int32_t ctr, int32_t amnt)
28496 {
28497 if(!game) return true;
28498 if(amnt <= 0) return true;
28499 switch (ctr)
28500 {
28501 case crMONEY: //rupees
28502 {
28503 if ( current_item_power(itype_wallet) ) return true;
28504 break;
28505 }
28506 case crMAGIC: //magic
28507 {
28508 if (get_qr(qr_ENABLEMAGIC))
28509 {
28510 return (((current_item_power(itype_magicring) > 0)
28511 ? game->get_maxmagic()
28512 : game->get_magic()+game->get_dmagic())>=amnt*game->get_magicdrainrate());
28513 }
28514 return true;
28515 }
28516 case crARROWS:
28517 {
28518 if(current_item_power(itype_quiver))
28519 return true;
28520 if(!get_qr(qr_TRUEARROWS))
28521 return checkCost(crMONEY, amnt);
28522 break;
28523 }
28524 case crBOMBS:
28525 {
28526 if(current_item_power(itype_bombbag))
28527 return true;
28528 break;
28529 }
28530 case crSBOMBS:
28531 {
28532 if(current_item_power(itype_bombbag)
28533 && itemsbuf[current_item_id(itype_bombbag)].flags & ITEM_FLAG1)
28534 return true;
28535 break;
28536 }
28537 }
28538 return (game->get_counter(ctr)+game->get_dcounter(ctr)>=amnt);
28539 }
28540 bool checkmagiccost(int32_t itemid, bool checkTime)
28541 {
28542 if(itemid < 0)
28543 {
28544 return false;
28545 }
28546 itemdata const& id = itemsbuf[itemid];
28547 return checkCost(id.cost_counter[0], id.cost_amount[0])
28548 && checkCost(id.cost_counter[1], id.cost_amount[1]);
28549 }
28550
28551 void payCost(int32_t ctr, int32_t amnt, int32_t tmr, bool ignoreTimer)
28552 {
28553 return;
28554 }
28555 void paymagiccost(int32_t itemid, bool ignoreTimer, bool onlyTimer)
28556 {
28557 return;
28558 }
28559
28560 void enter_sys_pal(){}
28561 void exit_sys_pal(){}
28562
28563 void replay_step_comment(std::string comment) {}
28564 bool replay_is_active() {return false;}
28565 bool replay_is_replaying() {return false;}
28566 bool replay_version_check(int min, int max) {return false;}
28567 bool replay_is_debug() {return false;}
28568
28569 #ifdef __EMSCRIPTEN__
28570 extern "C" void open_test_mode()
28571 {
28572 int dmap = -1;
28573 int32_t pal = Map.getcolor();
28574 for(auto q = 0; q < MAXDMAPS; ++q)
28575 {
28576 if(DMaps[q].map == Map.getCurrMap())
28577 {
28578 if(pal == DMaps[q].color)
28579 {
28580 dmap = q;
28581 break;
28582 }
28583 if(dmap < 0)
28584 dmap = q;
28585 }
28586 }
28587 if(dmap < 0) dmap = 0;
28588
28589 em_open_test_mode(filepath, dmap, Map.getCurrScr(), -1);
28590 }
28591
28592 extern "C" void get_shareable_url()
28593 {
28594 EM_ASM({
28595 ZC.setShareableUrl({open: UTF8ToString($0), map: $1, screen: $2});
28596 }, filepath, Map.getCurrMap(), Map.getCurrScr());
28597 }
28598 #endif
28599